-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(build): add ability to disable webpack's cache busting mechanism #3871
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
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.
|
I signed it! |
CLAs look good, thanks! |
I have an almost done PR (needs tests) that will allow finer control over the file hashing and that will cover your issue as well as another open issue regarding hashes on Dev builds. |
@tsm91 this PR looks like what I imagined it to be. Could you change the option name to A test is also needed. See https://github.com/angular/angular-cli/blob/master/tests/e2e/tests/build/chunk-hash.ts for the current one. @clydin your solution sounds interesting but lets discuss it in the #3853 instead. |
What I mentioned in that issue is different than the PR I mentioned above. I'll put out a WIP today. Instead of a Boolean option it allows three options: none; build (for a build unique hash); content (hash based on content). It also handles the file and URL loaders. |
I think 99% of the case people will either want to entrust webpack with cache busting or not. A simple toggle flag is more suitable.
I skipped the part where webpack process image and font files. I did it on purpose, because there is no backend solution for parsing css, finding file references and do cache busting there. On the other hand i do agree the default hashing behavior of file- and url loader is ugly.
Which means I also agree it would be a nice feature to allow finer control over the hashing mechanism. But it is not logical to do it with a command line flag. Something like this i could imagine {
"defaults": {
"cache-bust": {
"js-filename": "[name].bundle.js",
"js-chunk-filename": "[name].chunk.js",
"sourcemap-filename": "[name].bundle.map",
"css-filename": "[name].bundle.css",
"file-loader-name": "[name].[ext]",
"url-loader-name": "[name].[ext]"
}
}
} This way you could configure filename template placeholders for url- and file-loaders and bundle names. This way you have 100% control over cache busting and file naming. |
At that point, the config becomes a pseudo-webpack config. The encapsulation is important as webpack could very well be replaced in the future. I understand why you skipped the asset related loaders but having an option that advertises itself as disabling cache busting but only does it partially is kind of false advertising. |
Based on the discussion and described use cases, I adjusted the command option values. |
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. |
Optionally disable webpack's caching mechanism with the
-dcb
flag.Usecase: You want to solve cache busting of the generated bundles with a different strategy.
closes #3853