Update packages
- Install npm-check-updates by running
npm install -g npm-check-updates
- run
ncu
in terminal
- check all updated dependencies
- run
ncu -u
to update all dependencies in package.json
run ncu -u -x <name>
to exclude packages
- run
npm install
Remove unnecessary v4 packages
In webpack 5 some packages are no longer necessary because are now included. For us its usually this few:
- webpackbar
- terser-webpack-plugin
- optimize-css-assets-webpack-plugin
- friendly-errors-webpack-plugin
- file-loader
- run
npm uninstall webpackbar terser-webpack-plugin optimize-css-assets-webpack-plugin friendly-errors-webpack-plugin file-loader
Update your webpack.config.js
- Add caching
cache: {
type: 'filesystem',
cacheDirectory: path.resolve(__dirname, '.temp_cache'),
compression: 'gzip',
},
- remove
optimization
block
- remove plugins
WebpackBar
and FriendlyErrorsWebpackPlugin
- remove
file-loader
module
- remove "imports/require" like
TerserPlugin
, OptimizeCSSAssetsPlugin
, optimize-css-assets-webpack-plugin
, webpackbar
- Check this example for compare
Additional Information
Should an error message appear regarding PostCss. Delete the node_modules folder and the package-lock.json file and run npm install
again.