'AngularCli: disable minification
Is there a way to disable the minification in AngularCli?
After I launch the command ng build --prod I need to have all files.js, in dist folder, separate and legible.
Solution 1:[1]
Just do:
ng build --prod --optimization=false
That seems to do it. For more information see: https://github.com/angular/angular-cli/wiki/build
This is valid for angular 6.*
Solution 2:[2]
Note: If you use ng serve through some package.json run target, according to the manpage of Angular6 correspoding switch for this is:
ng serve --optimization=false
will speedup this bs in development noticeable
Solution 3:[3]
ng build --build-optimizer=false
Above command Enables '@angular-devkit/build-optimizer' optimizations when using the 'aot' option.
More details at https://angular.io/cli/build
Solution 4:[4]
The responses from 2018 are now outdated. For the more recent versions of Angular (13 as of this writing), the --optimization=false flag is deprecated. Instead, you can achieve the same result as follows:
In your angular.json, you can configure it for specific environment (e.g. no optimization in dev, but optimization in prod).
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"optimization": false,
...
}
}
}
You can also have more granular control on which optimizations are enabled:
"optimization": {
"scripts": true,
"fonts": false,
"styles": false
}
Those too can be further refined (e.g. for styles: minify, inlineCritical)
More details here: https://angular.io/guide/workspace-config#optimization-configuration
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | mschmoock |
| Solution 3 | |
| Solution 4 | Julien |
