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.

--public-url only works when set to / - No other options lead to a served JS file

See original GitHub issue

Original 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:38 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
warpechcommented, Jul 8, 2020

Tip: When you change --public-url/publicUrl, delete the .cache folder. I was getting incorrect results when I changed that setting but kept the cache.

7reactions
Slapboxcommented, Feb 20, 2018

@devongovett What do you think of an option to disable that behavior on 404s? It can make debugging more difficult.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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