You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And a more complicated example of using a CDN and hashes for assets.
config.js
output: {
path: "/home/proj/cdn/assets/[hash]",
publicPath: "http://cdn.example.com/assets/[hash]/"
}
I was able to get around this by setting my homepage to the unique string "$ASSET_URL" and then doing a find/replace on this string in a postbuild script:
Ah, what I forgot to mention is that I then set a global variable window.$ASSET_URL to whatever the CDN path is to the assets. It's a bit specific to my implementation (in this case a Visualforce site) but I'm sure you can tweak this basic idea to your needs. It's definitely a hack though and it would be nice to have some more customization ability around this.
@benknight Your initial solution would do it for me, but I get the further idea.
I guess the contributors are already thinking about this issue. After posting my issue and PR I saw another PR that aims to solve this issue with env variables but people weren't so fond of teaching env vars to beginners.
I'll keep watching this project until they give an answer on the subject, and if they don't allow this configuration of CRA I'll steal your code as it's better to keep in versioning control.
As of right now I'm hacking react-scripts on all PCs I use and put the code I mentioned at #1280
I have given second thoughts on this topic and didn't came up with a better idea on how to allow this configuration cleanly and easy...
Anyway, bring the popcorn and let's watch how this unfolds hahah
Activity
benknight commentedon Dec 19, 2016
I was able to get around this by setting my homepage to the unique string "$ASSET_URL" and then doing a find/replace on this string in a postbuild script:
benknight commentedon Dec 20, 2016
Ah, what I forgot to mention is that I then set a global variable
window.$ASSET_URLto whatever the CDN path is to the assets. It's a bit specific to my implementation (in this case a Visualforce site) but I'm sure you can tweak this basic idea to your needs. It's definitely a hack though and it would be nice to have some more customization ability around this.lucasavila00 commentedon Dec 21, 2016
@benknight Your initial solution would do it for me, but I get the further idea.
I guess the contributors are already thinking about this issue. After posting my issue and PR I saw another PR that aims to solve this issue with env variables but people weren't so fond of teaching env vars to beginners.
I'll keep watching this project until they give an answer on the subject, and if they don't allow this configuration of CRA I'll steal your code as it's better to keep in versioning control.
As of right now I'm hacking react-scripts on all PCs I use and put the code I mentioned at #1280
I have given second thoughts on this topic and didn't came up with a better idea on how to allow this configuration cleanly and easy...

Anyway, bring the popcorn and let's watch how this unfolds hahah
Timer commentedon Feb 11, 2017
Hi there!
react-scriptsv0.9.0 was just released which adds support for building for relative paths. You may read how to do so here.Please test it and don't hesitate to reach out if this doesn't solve your specific use case!