Dave Kalu
Dave Kalu

Reputation: 1595

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
        }
      }
    }
  }

Upvotes: 10

Views: 16358

Answers (2)

JiM-W
JiM-W

Reputation: 41

replaced by duplicate-package-checker-webpack-plugin

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

Upvotes: 4

PlayMa256
PlayMa256

Reputation: 6841

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

Upvotes: 12

Related Questions