trivago / parallel-webpack

Builds multi-config webpack projects in parallel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can we run webpack in production mode?

bsneha90 opened this issue · comments

In webpack we can specify production mode by adding a "-p" as explained in this link - https://webpack.js.org/guides/production/. What is the equivalent for it in parallel-webpack?

Hi @bsneha90,

parallel-webpack written with multiple builds in mind. We are using webpack's node API for creating a worker farm and run webpack builds with different configurations in parallel.

For your case I would suggest you to follow the manual way for your build. As defined in the webpack documentation -p parameter does following.

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

Which is roughly the same with the following config.

module.exports = {
  output: {
    path: path.join(__dirname, '/../dist/assets'),
    filename: '[name].bundle.js',
    publicPath: publicPath,
    sourceMapFilename: '[name].map'
  },

  plugins: [
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false
    }),
    new webpack.optimize.UglifyJsPlugin({
      beautify: false,
      mangle: {
        screw_ie8: true,
        keep_fnames: true
      },
      compress: {
        screw_ie8: true
      },
      comments: false
    })
  ]
}

Cheers,