Home  >  Q&A  >  body text

javascript - Calling webpack() function to compile in node environment

Call under node

webpack(webpackConfig)

Compile and find that the compiled code is not compressed. In the command line, you can use webpack -p to uglify the code. But how to pass the additional parameters such as -p -w -d when calling the webpack() function under node?

phpcn_u1582phpcn_u15822663 days ago784

reply all(1)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-07-05 11:01:47

    -p is just an abbreviation.

    https://webpack.js.org/api/cl...

    -p actually means:

    --optimize-minimize --define process.env.NODE_ENV="production"
    

    And --optimize-minimize means:

    • Minimize javascript and switches loaders to minimizing

    • Plugin used: UglifyJsPlugin & LoaderOptionsPlugin

    To build the package for the production environment, you can refer to this: https://webpack.js.org/guides...

    All command line parameters can be configured in config.

    reply
    0
  • Cancelreply