Production

Production

The following article describes the best practices and tools to use when using webpack to build a production version of a site or application.

The Automatic Way

Running webpack -p (or equivalently webpack --optimize-minimize --define process.env.NODE_ENV="production"). This performs the following steps:

  • Minification using UglifyJsPlugin
  • Runs the LoaderOptionsPlugin (see its documentation)
  • Sets the NodeJS environment variable triggering certain packages to compile differently

Minification

webpack comes with UglifyJsPlugin, which runs UglifyJS in order to minimize the output. The plugin supports al