Skip to content
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

Parameter "homepage" in package.json #1487

Closed
aaronplanell opened this issue Feb 6, 2017 · 8 comments
Closed

Parameter "homepage" in package.json #1487

aaronplanell opened this issue Feb 6, 2017 · 8 comments
Milestone

Comments

@aaronplanell
Copy link

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!!!

@gaearon
Copy link
Contributor

gaearon commented Feb 6, 2017

There are currently problems with "homepage": "." so while it works in some cases, it’s not recommended. #1480

The parameter itself is mentioned in the User Guide.

@aaronplanell
Copy link
Author

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!

@aaronplanell
Copy link
Author

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.

@gaearon gaearon added the docs label Feb 9, 2017
@Timer
Copy link
Contributor

Timer commented Feb 10, 2017

Addressed in #1489.

Let me know if the new documentation is sufficient, @aaronplanell!

@Timer Timer closed this as completed Feb 10, 2017
@Timer
Copy link
Contributor

Timer commented Feb 11, 2017

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!

@Timer Timer added this to the 0.9.0 milestone Feb 11, 2017
@MaxInMoon
Copy link

homepage: "." does not affect font-family css declarations..

@Johnny-jober
Copy link

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,

@ysfaran
Copy link

ysfaran commented Jan 2, 2019

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.

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants