support dynamic cdn prefix
What version of Remix are you using?
1.14.0
Are all your remix dependencies & dev-dependencies using the same version?
- [X] Yes
Steps to Reproduce
Unable to pass dynamic injection publicPath.
Expected Behavior
My resource path address is returned dynamically, so I hope can dynamically inject paths on static resources,just Like the webpack_public_path in the webpack.
I don't know how many people want to do this.Of course, I can submit a pr for Remix if necessary.
Actual Behavior
Dynamic prefixes are not supported
I'm not sure if anyone is concerned about this problem, or that there are other official solutions.
#6075
Hi @19Qingfeng, thanks for bringing this up. This is definitely something we'd like to support eventually, though it isn't a priority for us right now. Leaving this open for some future point at which we will tackle this problem.
Hi @19Qingfeng, thanks for bringing this up. This is definitely something we'd like to support eventually, though it isn't a priority for us right now. Leaving this open for some future point at which we will tackle this problem.
Okay, thank you very much. Maybe in my spare time recently, I can come up with some ideas to solve this problem and contribute to my PR.
+1 on this.
We deploy our Remix server to AWS ECS, but we specifically deploy the built frontend assets to S3 + Cloudfront for better performance in serving the frontend assets.
We want to deploy each version of our frontend assets to a different, dynamically and uniquely prefixed (eg, git hash) subfolder on S3. This allows us to quickly and easily roll-back the actual server, and still have old frontend assets be reachable. Otherwise, we have to redeploy the frontend assets and server rather than just rolling back.
Are there any workarounds available to dynamically modify publicPath?
+1 on this.
We deploy our Remix server to AWS ECS, but we specifically deploy the built frontend assets to S3 + Cloudfront for better performance in serving the frontend assets.
We want to deploy each version of our frontend assets to a different, dynamically and uniquely prefixed (eg, git hash) subfolder on S3. This allows us to quickly and easily roll-back the actual server, and still have old frontend assets be reachable. Otherwise, we have to redeploy the frontend assets and server rather than just rolling back.
Are there any workarounds available to dynamically modify
publicPath?
It seems that remix cannot implement this function at present, but I have modified the <Script /> component locally and the <Link /> component supports the splicing of host like <Script host="xxx" />, which can be satisfied for the time being.
Any news on this ? I think we can provide cdnPrefix to Script ?
You can do this by customizing the publicPath option in `remix.config file https://sergiodxa.com/tutorials/use-a-cdn-for-your-static-assets-in-remix, I imagine a similar thing can be achieved using Vite with some specific Vite option.
@sergiodxa That is helpful if your CDN path is predetermined (known at build time). But for dynamically hosted applications, it would be great to be able to set this at runtime. Hoping something like this can be implemented in the future.