Speed up Angular CLI build time excluding some optimization plugins
When building a big Angular project you will notice that the production build time might take several minutes and some times even over one hour. Of course you can skip the optimization by turning the optimization flag to false in your angular.json , but this way you will lose all of the optimizations. What we will try to do in this article is to turn off the module concatenation plugin in order to keep other plugins like the minification one.
Our projects runs Angular version 8.1.2 has over 1000 screens and the total build time for production is ~45 minutes.
My steps to skip the module concatenation process is the following:
- npm i -D @angular-builders/custom-webpack
"devDependencies": {
"@angular-builders/custom-webpack": "8.1.0"
2. Change the angular.json configuration to the following
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./extra-webpack.config.js"
},
3. Create a new file named extra-webpack.config.js next to angular.json with the following code
module.exports = {
optimization: {
concatenateModules: false
}
};
With the above configuration the total build time falls down to 19 minutes!