-
Notifications
You must be signed in to change notification settings - Fork 12k
dist/script.[hash].js wasn't be compressed with running ng build --prod command line #2796
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
Comments
Webpack's script-loader dumps the scripts in a giant The use of |
@clydin I didn't know that was why Going over the issue tracker for It is also possible to just pass in the minified scripts on the |
@filipesilva your welcome. Chaining an uglifier loader should fix the optimization problem but adds an additional 3rd party dependency and also doesn't solve the CSP issue. With the increasing stability of AOT support, stricter CSP configurations are becoming more viable. |
In this discussion about how/whether included scripts should get minified, there is an important practical factor that I believe is worthy of getting right. Some libraries (and in particular, of relevance to us hopefully here, Angular 1.x) ship a development build and a production/minified build, and the latter is not just the result of running the former through a minifier, but rather the result of additional, library specific differences between something intended for development versus production. Therefore, I believe the most correct answer to this is that the configuration file should accept two lists of scripts; one for development and another for production. As application authors we can then include the path of the correct corresponding library files. This yields smaller (and sometimes faster) results than just grabbing all of the development libraries and minifying them. As an additional convenience, it would be most ideal if there is a way to further ask CLI to minify third-party libraries which do not ship with the production build in the box. |
This could be accomplished by allowing both a string and an object in the However, some important questions to ask: how often will this be needed? And is it worth the added complexity and cost to maintain long-term? As to minifying, why not always minify during production builds and keep things simple? |
Certainly this keeps things simple. I think the goals of CLI include both simplicity for the application developer and high quality production-grade results. Each tradeoff that gets more of the first by sacrificing the second, pushes another increment of developers away from CLI to their own application-specific ad hoc process. |
@kylecordes, my last question was not meant to suggest the lack of need for the bifurcation of the scripts option. But instead meant to be more speculative; as in, even with the addition, why not always minify production? Especially if the scripts can be bundled and optimizations can be run as a whole. But there may well be edge cases that need to be considered. Personally and in a more general context, I've found that simplicity generally leads to higher quality production-grade results. More options leads to additional complexity which leads to a high cost toolchain and misconfigured projects. But, of course, simplicity and high quality are subjective and usually moving targets. |
Personally I think the most practical avenue is to always uglify/minify scripts. But there have been talks of having an alternative way of pulling in scripts in prod (e.g. from a CDN). That's definitely a feature for the future though. |
I think this is fixed by now. @filipesilva can you confirm? Closing this but should be reopened if there's still an issue. |
Unfortunately this still happens. Workaround is to use minified scripts. But we should fix it if we can. |
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix #2796 Fix #7226 Fix #7290 Related to #6872
Adds sourcemap and minification to javascript added via the `scripts` array in `.angular-cli.json`. `script-loader` is no longer used, which should help with CSP since it used `eval`. Scripts will no longer appear in the console output for `ng build`, as they are now assets instead of webpack entry points. It's no longer possible to have the `output` property of both a `scripts` and a `styles` entry pointing to the same file. This wasn't officially supported or listed in the docs, but used to be possible. Fix angular#2796 Fix angular#7226 Fix angular#7290 Related to angular#6872
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. |
OS?
Mac OSX Yosemite
Versions.
Repro steps.
The log given by the failure.
All pass no fail
Mention any other details that might be useful.
angular-cli.json
and run command line
ng build --prod
Here is a part of code about dist/script.[hash].js
You can see that, this pack wasn't be compressed
same as style
The text was updated successfully, but these errors were encountered: