question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

2reactions
rafa-ascommented, Jun 26, 2020

Unfortunately not @Spawnrad . I still have to add the issue about this problem.

EDIT: @spawnrad you can track the issue here #18042

1reaction
dgp1130commented, May 28, 2020

@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 the styles 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found