Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: webpack.optimize.DedupePlugin is not a constructor

I keep getting the error: TypeError: webpack.optimize.DedupePlugin is not a constructor when I try to build my React application with the following webpack.config.js. I am using webpack version "^4.0.1". Thank you.

plugins: [
    new webpack.HotModuleReplacementPlugin()
    // new webpack.DefinePlugin({
    //   'process.env.NODE_ENV': JSON.stringify('production')
    // })
  ],
  optimization: {
    minimize: false,
    minimizer: [
      new webpack.DefinePlugin({
        // <-- key to reducing React's size
        'process.env': {
          NODE_ENV: JSON.stringify('production')
        }
      }),
      new DedupePlugin(), //dedupe similar code
      new UglifyJsPlugin(), //minify everything
      new AggressiveMergingPlugin() //Merge chunks
    ],
    runtimeChunk: true,
    splitChunks: {
      chunks: 'async',
      minSize: 1000,
      minChunks: 2,
      maxAsyncRequests: 5,
      maxInitialRequests: 3,
      name: true,
      cacheGroups: {
        default: {
          minChunks: 1,
          priority: -20,
          reuseExistingChunk: true
        },
        vendors: {
          test: /[\\/]node_modules[\\/]/,
          priority: -10
        }
      }
    }
  }
like image 592
Dave Kalu Avatar asked Oct 16 '18 12:10

Dave Kalu


2 Answers

There is no dedupe plugin on version 4 anymore, that is why.

like image 198
PlayMa256 Avatar answered Oct 22 '22 02:10

PlayMa256


replaced by duplicate-package-checker-webpack-plugin

https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin

like image 27
JiM-W Avatar answered Oct 22 '22 02:10

JiM-W