-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@angular/cli): add --compress option #4618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@@ -108,7 +108,7 @@ export default Task.extend({ | |||
stats: statsConfig, | |||
inline: true, | |||
proxy: proxyConfig, | |||
compress: serveTaskOptions.target === 'production', | |||
compress: serveTaskOptions.target === 'production' && serveTaskOptions.compress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be serveTaskOptions.compress
once the option default is based on build target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -25,6 +25,12 @@ export const baseBuildCommandOptions: any = [ | |||
{ name: 'locale', type: String }, | |||
{ name: 'extract-css', type: Boolean, aliases: ['ec'] }, | |||
{ | |||
name: 'compress', | |||
type: Boolean, | |||
default: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
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
production
mode. 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
false
This is perfectly fine, since Webpack installs a plugin by calling its
apply
method, passing a reference to the Webpack compiler object.Related Issues
Related Pull Requests