-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Loading chunks from CDN with precompiled assets #2219
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
Interesting. I work with @lavaturtle and #1782 also may be an issue for us since we have some customers who consume our product as a self-hosted docker image. It may only happen to work so far because none of them have a CDN. It seems like the ideal behavior is to load chunks relative to the pack file always? Rather than relative to the app root? The current behavior is not the complete end of the world (our app can serve the files most of the time, just slightly slower), but it would be better if everything always loaded from the CDN. It can lead our users to sometimes experience chunk 404s while deploys are rolling out across our fleet. If everything was loading from the static asset CDN the old pack chunks would be live on the CDN even after new code had been deployed. |
For what it's worth we're running Webpacker |
The
Having old pack chunks on the CDN probably would not be an issue since the file/chunk names are hashed by content. Apart from all that, if there's a new feature that you want to see added, you'll need to write the code yourself. You can also send feature ideas in an email to the rails-core mailing list. Hope this helped. |
I don't think you actually read this very thoroughly. Packs and chunk requests going to different hosts is the expected behavior? Okay! 🤷♂ |
All we want is to load chunks relative to the pack that was generated. This might not be possible I guess. |
Like I said if you precompile packs before they are distributed as docker images, public_root_path & public_output_path are locked, they can not change dynamically. As you said, you can probably get away with statically defining your CDN when you precompile the packs before saving the docker image. If you want to troubleshoot the issue, please post some example files to a gist.github.com (or, even better, an example repo) and hopefully I can be more specific. |
In our app, we precompile assets, and use the same assets on staging and production environments. Also, we use a different CDN on staging vs. production environment.
The pack .js files load correctly from the CDN, but the chunks are then loaded from our app instead of from the CDN. Is there any way to configure things so the chunks come from the CDN as well?
We considered setting WEBPACK_ASSET_HOST during precompilation, but this would require hard-coding one CDN or the other, when we in fact want it to be environment-dependent.
(This may be similar to #1782 but I'm not sure if that one has already been addressed.)
Thank you!
The text was updated successfully, but these errors were encountered: