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
}
}
}
}
There is no dedupe plugin on version 4 anymore, that is why.
replaced by duplicate-package-checker-webpack-plugin
https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With