简体   繁体   中英

Webpack incremental production build

I have a webpack project, which is built together with another components by SBT. The webpack production build compiles the src provides me with a dist folder, which is built from the src folder, and rest is copied assets. Each time I run the build process, I remove the dist folder, and create it again. I wonder if there is any way to config webpack, to do the build process only if something is really changed, and if yes, to build the dist incrementally. (Im not talking about the watch option, which is for dev time).

Thanks

I would not do incremental production builds. As you point out, using watch for dev time is fine, but you likely have very different source mapping, minification, etc. settings for your production builds (see webpack guide on development vs. production builds ).

But if you are manually removing the /dist folder before every production build, you can at least automate that step with the CleanWebpackPlugin .

From the command line, run:

npm install clean-webpack-plugin --save-dev

Then in your webpack.config.js , add it to the plugins section:

plugins: [
  new CleanWebpackPlugin(["dist"])
],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM