Hi,
I miss an explanation at the documentation about the parameter _"homepage"_ in _package.json_, and it is very useful for making buildings.
For instance, I had a problem because the _index.html_ file pointed to _"/static/js/...js"_ and that's is correct if we release the application in the _root_ folder, but if you have various static developments in the same machine using the same _Apache Server_ you have a problem.
I configured _package.json_ with:
"homepage": "."
That made that instead of using absolute paths we use relative paths in the current folder. What I mean: _"./static/js/...js"_
I think that this information will be useful to other developers.
Thanks a lot for your work!!!
There are currently problems with "homepage": "." so while it works in some cases, it鈥檚 not recommended. https://github.com/facebookincubator/create-react-app/issues/1480
The parameter itself is mentioned in the User Guide.
Hey,
Thanks a lot Dan. Sorry, I checked the Readme.md file, not the User's Guide. It's my fault.
In any case, the issue #1480 says:
"homepage": "./"
And, I propose:
"homepage": "."
I know that it's a hack and that's not officially supported by CRA, but it worked for me. Maybe, and this is a proposal, the build must point to the relative folder of the index file, instead to the root. What do you think about it?
Best regards!
Sorry, about the relative folder, I just read your comment:
The main reason being it's a footgun for apps with client-side routing. For example, people visiting http://myapp.com/todos/42 still want to load http://myapp.com/static/js/main.123.js, not http://myapp.com/todos/42/static/js/main.123.js
At the issue #1094.
I think that if I don't use _react-router_ I won't have any problem.
Addressed in https://github.com/facebookincubator/create-react-app/pull/1489.
Let me know if the new documentation is sufficient, @aaronplanell!
Hi there! react-scripts v0.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!
homepage: "." does not affect font-family css declarations..
Hello @Timer Thanks a lot for your this 'relative path' contribution.
I have a problem with my specific use case.
To generalize my question, I have set up the environment using express-generator and I created CRA inside public folder, named as 'client'
just in case if you could see the entire source, it is HERE
I would desperately want to use client side routing (react-router v4)
and hopefully also Redux in the future..
Could you please take a look when you get a chance please?
Very much appreciated,
homepage: "."does not affect font-family css declarations..
This happened also to me! You most likely used react-scripts-ts instead of react-scripts in your package.json.
Most helpful comment
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!