remix icon indicating copy to clipboard operation
remix copied to clipboard

support dynamic cdn prefix

Open 19Qingfeng opened this issue 2 years ago • 9 comments

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

19Qingfeng avatar Mar 24 '23 09:03 19Qingfeng

I'm not sure if anyone is concerned about this problem, or that there are other official solutions.

19Qingfeng avatar Mar 29 '23 06:03 19Qingfeng

#6075

19Qingfeng avatar May 06 '23 08:05 19Qingfeng

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.

mjackson avatar Aug 14 '23 18:08 mjackson

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.

19Qingfeng avatar Aug 15 '23 13:08 19Qingfeng

+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?

cbreezier avatar Nov 01 '23 10:11 cbreezier

+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.

19Qingfeng avatar Nov 04 '23 11:11 19Qingfeng

Any news on this ? I think we can provide cdnPrefix to Script ?

revskill10 avatar May 05 '24 06:05 revskill10

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 avatar May 05 '24 06:05 sergiodxa

@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.

emcdonald avatar Jul 18 '24 18:07 emcdonald