Как минимизировать с помощью TerserPlugin и webpack-encore - PullRequest
0 голосов
/ 28 июня 2019

С этим webpack.config.js, который использует webpack-encore и минимизирует с помощью terser, я могу успешно скомпилировать, но абсолютно ничего не минимизируется.Комментарии и полные имена переменных все еще там.

var Encore = require('@symfony/webpack-encore');

const TerserPlugin = require('terser-webpack-plugin');

Encore
    // the project directory where compiled assets will be stored
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    // the public path used by the web server to access the previous directory
    .cleanupOutputBeforeBuild()
    .enableSourceMaps(!Encore.isProduction())
    .enableReactPreset()
    .enableSassLoader()
    .enableLessLoader()
    .autoProvidejQuery()
    .disableSingleRuntimeChunk()

     .addEntry('app_prescription', [
         './assets/js/prescription/app_prescription.js'
     ])



    .addLoader({
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: "babel-loader?cacheDirectory"
    })

;


if( Encore.isProduction() ) {
    Encore.addPlugin(new TerserPlugin({parallel: true,cache:true}) );
}

module.exports = function(env) {

    Encore.enableVersioning();
    const config = Encore.getWebpackConfig() ;

    if( Encore.isProduction() ) {

        config.optimization = {
            minimizer: [new TerserPlugin({parallel: true,cache:true})]
        }
    }



    return config ;
}

Что не так с этим кодом?

...