-
-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow more customization to homepage option #1279
Comments
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: {
// ...
"homepage": "$ASSET_URL",
"devDependencies": {
// ...
"replace": "^0.3.0"
},
"scripts": {
// ...
"postbuild": "npm run replace",
"replace": "replace '\\$ASSET_URL/static' '..' build -r -s --include='*.css' & replace '\\$ASSET_URL' '\"+window.$ASSET_URL+\"' build -r -s --include='*.js' & replace '\\$ASSET_URL/' '/' build -r -s --include='*.html'"
},
} |
Ah, what I forgot to mention is that I then set a global variable |
@benknight Your initial solution would do it for me, but I get the further idea. 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... |
Hi there! Please test it and don't hesitate to reach out if this doesn't solve your specific use case! |
The current setup doesn't allow to use CRA and a CDN if index.html isn't in the same url as the other assets.
Setting the homepage on package.json to "https://somethig.com" will pass "/" as publicPath to webpack.
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L38
That's fine.
But I'd like to serve all assets at a CDN (Firebase) and render "index.html" dynamically elsewhere (AWS Lambda) to add custom meta tags per route, as suggested here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server.
But then I have to set my publicPath to use Firebase's link.
At webpack's docs they say they support it:
https://github.com/webpack/docs/wiki/configuration
I wouldn't like to eject just for this, so, what do you guys think about letting me skip this logic https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L44 and set the publicPath I want?
Perhaps escaping the homepage field with a special char like "@https://foo.firebaseapp.com/" will disable https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L44
Proposed POC for this "fix" I came up with: #1280
Thanks for the great work you've been doing on this project 👍
The text was updated successfully, but these errors were encountered: