Webpack how to build production code and how to use it

前端 未结 8 1022
梦谈多话
梦谈多话 2020-11-29 15:06

I am very new to webpack, I found that in production build we can able to reduce the size of overall code. Currently webpack builds around 8MB files and main.js around 5MB.

8条回答
  •  無奈伤痛
    2020-11-29 15:55

    You can add the plugins as suggested by @Vikramaditya. Then to generate the production build. You have to run the the command

    webpack -p --config ./webpack.production.config.js
    

    The -p tells webpack to generate a production build. You have to change the build script in package.json to include the production flag.

提交回复
热议问题