-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Building does not set relative paths to the assets in static
folder
#527
Comments
Did you get a chance to read the instructions posted in the console when the build finishes? I believe they should explain how to fix the problem. If not can you please show a screenshot of |
Sorry about that. I just found out about "homepage" in the code. I'll close. |
No worries, I just want to verify the build outputs instructions correctly. |
I confirm that now I ejected/reverted then npm i-ed my codebase, I can see the instructions after building. I don't know how I did miss that output before - it is exactly on point. Thanks for your time! |
Got it, thanks for explaining. It was added relatively recently so if you ejected, you might have used an earlier version at the time. |
@gaearon What if I want to have the site at multiple places? Would I have to keep changing the homepage and run build?? Is there a way I can heave the links in the build/index to not have the leading slash? |
The problem with what you're suggesting is that this breaks client sure routing. The vast majority of newly built React apps have client side routing. Many people new to that idea get confused when their JS stops working because they loaded I think as a workaround you can specify |
@gaearon Thanks for the tip. A good set of people also use it for parts of an application and not necessarily the entire application or in subfolders. Just to float everyone's boat I think we can put that workaround './' in the README so that they know. |
If it works, sure, feel free to send a PR to usage guide! |
./ not worked for me.
style.css
the final build\static\css\main.cfecb7b9.css
then the browser will fail to get the jpg
I develop app for mobile, and we need put build folder to anywhere on mobile. |
I make it work with the blow steps
|
Going to reopen this and tag as a bug so we come back to this later. |
Hi there! Please test it and don't hesitate to reach out if this doesn't solve your specific use case! |
@Timer I have what I think is an interesting use case. i'm running my dev environment in vagrant, and proxying create react app running locally on my host os(os x). I would like to have the local paths be relative as well, so something like if homepage was set to is there a way to have it set the path this way when developing locally as well? I may end up having multiple CRA based apps, and want them all under sub paths running locally. is there a way to do this? |
You probably want #1582, although even that wouldn't let you run multiple servers on one port I think. |
@Timer Hello i just changed to |
@Timer I've created a PR for this issue mentioned by @fernando-gl |
@Timer @robinvdvleuten I am not sure how |
@fernando-gl Please file a new issue with instructions to reproduce and a demo. This is the kind of issue that is very hard to discuss without an example. Thanks! |
This is still a problem, which I have had to fix with a rewrite rule in the web server serving the production build. Example below, and a small recipe for the rewrite rule required as well. DescriptionGiven a CSS file ("global.css") which links to a font placed within the static folder public/fonts:
In order to work in development mode, the entry in global.css must contain the entry
Assuming that the context path of the production build should be However, running the
(Somewhat clunky) Workaround recipe
The sub_filter above effectively replaces the malformed URLs embedded in the compiled CSS resource so that the outbound links work for clients. |
Dec 2017 update: Just put the |
I have problem when build my react app and then do command npm i -g serve , then serve -s build -p 80, because wish first looking my app on wamp widrh apche server on port 80. |
I wanted to change default url for create-react-app from " localhost:3000 " to "localhost:3000/something" in development env and i don't want to run eject. Being a newbie to create-react-app am unable to do so. please give me solution if anyone have . Thanks in advance |
Hi @srbin25 @AmitUmrikar please open an new issue if you have a new question, thanks! |
This leads to problems when adding the built react app in a subfolder of a static website (my github.io page is a good example of the use case, the folder
/react-range-progress
contains a react app built withcreate-react-app
, but does not find the assets if I do not changeto:
in the first case, the browser will look for the js file in the root folder.
The text was updated successfully, but these errors were encountered: