-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Applications served from cdn on different host #647
Comments
I have a similar issue. I need the resulting index.html to have its link and script tags point to a url that has a CDN url prefixed to the fingerprinted assets. Right now I see no way of achieving this without abusing the homepage property in package.json by doing Would it be possible to do something like |
I'm in the process of forking create-react-app to handle a few things specific to my companies needs, which includes this feature. (I've implemented it as process.env.HOMPAGE) currently. I could make a pr for this if it's coherent with create-react-app's scope and philosophy. |
I need the same stuff as well. I have made a small change to the build script and added |
I’m open to merging support for |
Working on it |
closes facebook#647 Previously we only allowed settings the pathname via the "homepage" key in package.json Allows user to configure the full base URL via a $CDN_URL env variable Development has the same behaviour.
I solved a similar problem where I needed absolute urls in development builds.
and imported it right at the top of the index.js.
It's kind of important that it is imported before any other file and just defining the variable insidethe index.js also does not work because all imports are hoisted to the top of the file. |
Interesting. We don’t officially support this so it might break in the future. |
Yep, it's a hack and probably should not even work. That would make this project even easier to integrate into non-js backends. |
Right now I’m wary of increasing surface area for bugs. I don’t want to make this as complicated as WDS client. I still plan to make changes to it, so I intend to keep it scoped to features CRA supports, and serving JS from a different host or port is not supported right now. |
This seems a bit related to PR #937. Adding for context. |
Hi there! Please test it and don't hesitate to reach out if this doesn't solve your specific use case! |
Going to close this. |
I'm in the process of converting our companies internal boilerplate into something that uses create-react-app.
We load all of our applications into html rendered by rails views in our application. Js/css/etc built by webpack is served via cdn.
In our boilerplate we look in the env for CDN_URL and set that as publicpath. This cdn url is provided in local dev by a .env file (loaded via dotenv module) and during deploys by the build server.
In trying to keep with 12 factor app methodology we don't commit these urls to the codebase.
Seems like publicpath is only currently modifiable by editing package.json.
Would it be possible to use something like REACT_APP_STATIC_URL (or any other, better name) in order to construct the publicpath for webpack?
The text was updated successfully, but these errors were encountered: