Relative paths in dist for assets
See original GitHub issueLocal server works great with images and stylesheets. However on output I have that causes images and stylesheet paths to break for subdirectory routes.
Output structure:
dist/
- index.html
- styles.css
- img/image.jpg
- about/index.html
The about/index.html
references the stylesheet as ./style.css
which should be ../style.css
and the same for the image img/image.jpg
should be ../image.jpg
.
My src structure is setup so that each component has all of its assets next to it. The images and styles do get bundled into the style.css and img directory respectively.
Source Structure:
src/components/about/
index.jsx
__tests__/about.test.jsx
img/image.jpg
scss/about.scss
Not sure if this is an issue with react-static or webpack in general but placing here since react-static controls the output.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Relative paths in dist for assets #156 - react-static ... - GitHub
jpg . My src structure is setup so that each component has all of its assets next to it. The images and styles...
Read more >How to solve vue.js prod build assets relative path problem
I copied the dist folder to one of my wamp apache server's www folder. I browsed the project from the browser and I...
Read more >Relative fs.readFileSync paths with Node.js - Ultimate Courses
In this post you'll learn how to use fs.readFileSync to give you a relative path to your asset. By default, that's not the...
Read more >Static Asset Handling - Vite
Importing a static asset will return the resolved public URL when it is served: ... public paths (based on project root during dev)...
Read more >Angular 5 fix relative path for Assets/ folder - Stack Overflow
How can I make Angular 5 to find my assets path relatively? In my case having a call on http://localhost:7777/test/assets/image.png.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
Figured it out. The
publicPath: ''
needed to bepublicPath: '/'
for the loadershere’s the output of about/index.html