question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building does not set relative paths to the assets in `static` folder

See original GitHub issue

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 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:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

25reactions
gaearoncommented, Aug 31, 2016

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?

24reactions
Timercommented, 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!

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found