Webpack: How can we *conditionally* use a plugin?

后端 未结 7 2198
死守一世寂寞
死守一世寂寞 2021-02-07 00:31

In Webpack, I have the following plugins:

plugins: [
        new ExtractTextPlugin(\'styles.css\'),
        new webpack.optimize.UglifyJsPlugin({
            com         


        
7条回答
  •  深忆病人
    2021-02-07 01:19

    Without variables it will look like this:

        plugins: [
            new ExtractTextPlugin('styles.css'),
            (TARGET === 'build') && new webpack.optimize.UglifyJsPlugin({
                compress: {
                    warnings: false
                },
                drop_console: true,
            }),
        ].filter(function(plugin) { return plugin !== false; })
    

提交回复
热议问题