You can fine tune several Webpack plugins to make your bundle as small as it can is for your specific application. However there is a few things you can does for pretty much every application to make it smaller and run faster. In this lesson we'll combine several webpack plugins to optimize things for a React application (this is also applicable F or non-react applications as well).
First we need to modify the Prod scripts from:
" Build:prod " " Webpack--env.prod-p ",
To:
" Build:prod " " Webpack--env.prod ",
Help methods:
Plugins:removeempty ([//doesn ' t save anything in this small app. [e-mail protected] mostly takes care of thisIfprod (NewWebpack.optimize.DedupePlugin ()),//saves a couple of kBsIfprod (NewWebpack. Loaderoptionsplugin ({ //loader plugin only works in Webpack 2 Minimize:true, Debug:false, quiet:true, })), //saves KB with uglify!! Saves KB withoutIfprod (NewWebpack. Defineplugin ({'process.env': {node_env:'"Production"', }, })), //saves 711 kb!!Ifprod (NewWebpack.optimize.UglifyJsPlugin ({compress: {screw_ie8:true,//Eslint-disable-lineWarningsfalse, }, })), ])
[Webpack 2] Optimize React size and performance with Webpack production plugins