ng build --prod still does NOT minify / uglify / remove comments using angular-cli 9 (and 8)
See original GitHub issueπ Bug report
Command (mark with an x
)
- new
- [x ] build
- serve
- test
- e2e
- generate
- add
- update
- lint
- xi18n
- run
- config
- help
- version
- doc
Is this a regression?
Yes, but I don't know what is the previous version in which this bug was not present.Description
When I build my Angular project with ng build --prod, all comments remain in the html, spaces aren't removed, etc. Seems like no minification / uglification / comment removal is taking place.π¬ Minimal Reproduction
Simply: ng build --prod
(run on a basic project with an html comment in index.html
π₯ Exception or Error
No exception, just doesnβt minify / uglify / remove comments when it should.
π Your Environment
Angular CLI: 9.1.3
Node: 12.16.2
OS: win32 x64
Angular: 9.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.3
@angular-devkit/build-angular 0.901.3
@angular-devkit/build-optimizer 0.901.3
@angular-devkit/build-webpack 0.901.3
@angular-devkit/core 9.1.3
@angular-devkit/schematics 9.1.3
@angular/cdk 9.2.1
@angular/material 9.2.1
@ngtools/webpack 9.1.3
@schematics/angular 9.1.3
@schematics/update 0.901.3
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
Anything else relevant?
Iβm running this on Windows 10 x64, if that matters.
Somewhat duplicate of https://github.com/angular/angular-cli/issues/9973, however still not solved in Angular 8 or 9 (I had 8 and upgraded to 9 in the hopes that it would be fixed there, but it isnβt). Also, the previously suggested workaround of running ng build --target=production --environment=prod
doesnβt work, it gives an error message:
Unknown option: '--target'
Unknown option: '--environment'
Thanks!!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14
Top Results From Across the Web
ng build --prod does NOT minify / uglify / remove comments ...
The issue is in angular.json file. Under the key projects.MY_PROJECT_NAME.architect.build.configurations.production , I was missing all theΒ ...
Read more >Minify / Uglify / remove comments your final Angular build
Removing unwanted code and minifying your application is a crucial step before pushing to production. To fix this, just open up angular.json config...
Read more >Deployment - Angular
After the command produces an optimal build of your application (equivalent to ng deploy --prod ), it'll upload the production assets to Firebase....
Read more >Building an Angular Application for Production - Minko Gechev
Im using angular-cli with ng build --env=prod but it doesn't gzip... My vendor and my main files aren't minified. What can I do?...
Read more >ng build - Angular
Option Description Value Type Default Value
ββaot Build using Ahead of Time compilation. boolean true
ββbaseβhref Base url for the application being built. string
ββdeleteβoutputβpath Delete...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately not @Spawnrad . I still have to add the issue about this problem.
EDIT: @spawnrad you can track the issue here #18042
@eranzim, can you provide a minimal repro of what you are seeing? Itβs hard for us to debug further without one.
/*!
comments are not stripped and CSS using thestyles
decorator option is not minified, so those are both working as expected. If you can get a minimal reproduction of the template HTML persisting in a prod build, we can look into that further.@rafa-as, can you open a new issue for what youβre seeing? It will be easier to debug/track that in a separate issue.