Angular-cli: How can remove some lines before build

Created on 9 Jul 2017  路  3Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Versions.

@angular/cli: 1.1.3
node: 7.10.0

How can remove some lines before build

I'm putting logs in my code for debugging and logging. These logs are putted in every file, every function. I can simple build my app by ng build or ng build --prod. Problem is if I remove all logs from my app dist folder size can be decrease. I don't want to remove logs for debug environment, but I wan't to remove all logs file before build it.

I search about this problem, but I i did't get any proper solution.

How can I achieve this.

3 (nice to have) inconvenient

Most helpful comment

Whilst researching this issue I found the drop_console option in uglify js. I don't know how well it work, but it could be a super easy way to implement this.
https://github.com/mishoo/UglifyJS2/blob/v2.x/README.md

I guess it would need to be passed into the webpack production config here:
https://github.com/angular/angular-cli/blob/67646796d977bd476c3f618dd64a6c2b6c4ddcae/packages/%40angular/cli/models/webpack-configs/production.ts#L89

All 3 comments

Maybe Angular itself will support it one day. See Igor's review for https://github.com/angular/angular/pull/17399.

Whilst researching this issue I found the drop_console option in uglify js. I don't know how well it work, but it could be a super easy way to implement this.
https://github.com/mishoo/UglifyJS2/blob/v2.x/README.md

I guess it would need to be passed into the webpack production config here:
https://github.com/angular/angular-cli/blob/67646796d977bd476c3f618dd64a6c2b6c4ddcae/packages/%40angular/cli/models/webpack-configs/production.ts#L89

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings