feat(@angular/cli): add --compress option#4618
feat(@angular/cli): add --compress option#4618cherryland wants to merge 1 commit intoangular:masterfrom cherryland:add-compress-option
Conversation
Add compress option to toggle gzip compression in production mode
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
Awaiting #4596 to add e2e end-to-end tests |
|
CLAs look good, thanks! |
| test: /\.js$|\.html$|\.css$/, | ||
| threshold: 10240 | ||
| }) | ||
| buildOptions.compress ? |
There was a problem hiding this comment.
It would be cleaner if a check was done above for buildOptions.compress and then the plugin was added onto extraPlugins. This should probably be moved into common instead if it's now configurable or a warning issued if it is only supported for production.
@filipesilva thoughts on this?
| inline: true, | ||
| proxy: proxyConfig, | ||
| compress: serveTaskOptions.target === 'production', | ||
| compress: serveTaskOptions.target === 'production' && serveTaskOptions.compress, |
There was a problem hiding this comment.
This should just be serveTaskOptions.compress once the option default is based on build target.
There was a problem hiding this comment.
We need to make sure, that the compress option will only be available in combination with -t production, but this behavior can be changed in general
| { name: 'extract-css', type: Boolean, aliases: ['ec'] }, | ||
| { | ||
| name: 'compress', | ||
| type: Boolean, |
There was a problem hiding this comment.
The default here can be removed as it can be set based on build target. This can be done by adding the option values here: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/webpack-config.ts#L79
There was a problem hiding this comment.
This can be done by adding the option values here: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/webpack-config.ts#L79
It already is
The default here can be removed
I disagree, the default value may be redundant here, but is also included in the CLI help output
There was a problem hiding this comment.
Except the default is false for the development target which makes it misleading in its current form. I know it says production in the description but even a small amount of ambiguity can lead to confusion.
Either way, help should eventually support displaying target specific defaults.
There was a problem hiding this comment.
The option will be ignored when -t=development, see https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/webpack-config.ts#L59
|
Hi @0xcherry, After an offline discussion here with the team we decided to remove the compression plugin entirely. The reasoning is that there is an easy workaround, it's noise and the service worker is buggy with it. Could you transform this PR with:
If you need any help with the above steps let me know. Cheers! |
|
Superseded by #4702 |
|
I can't find compress doc in https://github.com/angular/angular-cli/tree/master/docs/documentation |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
By default, gzip compression is enabled in
productionmode. There are several use cases, where gzip compression might not be supported and/or requiredUsage
or
Example Output
Basic Implementation
We simply wrap the plugin with a conditional operator and void the output, if the expression evaluates to
falseThis is perfectly fine, since Webpack installs a plugin by calling its
applymethod, passing a reference to the Webpack compiler object.Related Issues
Related Pull Requests