--public-url only works when set to / - No other options lead to a served JS file
See original GitHub issueOriginal file: /projectRoot/app/app.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MyApp</title>
<link rel='stylesheet' src='app.global.css' />
</head>
<body tabindex="-1" disabled="disabled" focusable="false" aria-label="">
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>
Output file: /projectRoot/dist/app.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MyApp</title>
<link rel="stylesheet" src="app.global.css">
</head>
<body tabindex="-1" disabled="disabled" focusable="false" aria-label="">
<div id="root"></div>
<script src="/dist/c91b3d0cbbf15cbf3cda41e594a40ff1.js"></script>
</body>
</html>
The Javascript src is always pointing to the dist folder a level deeper than it should. I cannot find any way to correct this. Any thoughts? Thanks very much.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 1.6.1 |
| Node | 8.9.1 |
| npm/Yarn | 1.3.2 (yarn) |
| Operating System | Windows 7 x64 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:38 (5 by maintainers)
Top Results From Across the Web
Can't build create-react-app project with custom PUBLIC_URL
I cloned create-react-app from GitHub and have been browsing the code but have not yet been enlightened. Does anyone have any suggestions as...
Read more >Wrong path for css and js file on build · Issue #323 - GitHub
I agree that --public-url ./ seems like it should be a default. My simple CSS and JS references in an HTML file does...
Read more >Using the Public Folder - Create React App
The public folder contains the HTML file so you can tweak it, for example, to set the page title. The <script> tag with...
Read more >Static Asset Handling - Vite
Importing a static asset will return the resolved public URL when it is served: js import imgUrl from './img.png' document.getElementById('hero-img').src = ...
Read more >Serve Static Resources with Spring - Baeldung
This article shows how to cache your static assets such as Javascript and CSS files when serving them with Spring MVC. Read more...
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

Tip: When you change
--public-url/publicUrl, delete the.cachefolder. I was getting incorrect results when I changed that setting but kept the cache.@devongovett What do you think of an option to disable that behavior on 404s? It can make debugging more difficult.