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

后端 未结 7 2203
死守一世寂寞
死守一世寂寞 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:26

    You can use this new syntax which uses the spread operator

    plugins: [
        new MiniCssExtractPlugin({
            filename: '[name].css'
        }),
        ...(prod ? [] : [new BundleAnalyzerPlugin()])
    ],
    

提交回复
热议问题