[Webpack 2] Optimize React size and performance with Webpack production plugins

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.