Building does not set relative paths to the assets in `static` folder
See original GitHub issueThis 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 with create-react-app
, but does not find the assets if I do not change
<script type="text/javascript" src="/static/js/main.36dfbdaf.js">
to:
<script type="text/javascript" src="static/js/main.36dfbdaf.js">
in the first case, the browser will look for the js file in the root folder.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:16
- Comments:24 (13 by maintainers)
Top Results From Across the Web
reactjs - Relative path in index.html after build - Stack Overflow
I'm using Photino.io building React JS to create UI for .NET cross-platform apps & the package.json was not using this so it couldn't...
Read more >React tips — Working with relative path using create-react-app
First create a folder called Api and add a Item.js file. And a folder called Components with subfolders ListItems and Item as we...
Read more >Deployment | Create React App
Building for Relative Paths ... By default, Create React App produces a build assuming your app is hosted at the server root. ......
Read more >Build & Deploy - Hands on React
The build folder with static assets is the only output produced by Create React App. However this is not quite enough if you...
Read more >Set the relative path of assets in a CRA app - Today I Learned
When I build my CRA app I get a path for my assets (css, images) that begins with /static . If I deploy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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
npm run build
output?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!