Choose one: This is a 馃悰 bug report
Inside my index.html I have an anchor href that refers to other html in other folder. For some reason Parcel output includes a script tag to a js file that cannot be found. Of course, the browser fails to load the generated page because of that.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Home Page</title>
</head>
<body>
I agree to all the <a href="docs/terms.html" target="_blank">terms of use</a>
</body>
</html>
docs/terms.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Terms of Use</title>
</head>
<body style="background-color: yellow">
Terms of Use:
</body>
</html>
CLI command
parcel index.html
Valid output of index.html, that referes correctly to docs/terms.html
In the generated index.html file, the header looks like this:
<head>
聽 <meta charset="utf-8">
聽 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
聽 <title>Home Page</title>
聽 <script src="/terms.js"></script> Invalid location!
</head>
the output includes also docs folder with terms.html and terms.js, that contains Parcel code. However the script src above is invalid, and the page fails to load in the browser because of that.
Refer correctly to the generated js file.
Testing Parcel for building static site.
Provided above.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel CLI | 1.12.1
| Node | 10.13.0
| npm/Yarn | 6.4.1
| Operating System | Windows 10
Same problem with Parcel 1.12.3, but it works in version 1.9.7
I'm having the exact same issue in my project with Parcel 1.12.3, Node 10.15.3, and Yarn 1.15.2, on Windows 7. I can confirm that the issue does not happen in Parcel 1.9.7
I've noticed that this only happens when running parcel or parcel watch but _not_ parcel bundle
In the meantime, downgrading to Parcel 1.9.7 appears to work for me.
--no-hmr should be a workaround if you don't need HMR.
parcel build index.html --public-url ./ solved referring problem for me with Parcel 1.12.3
Confirm bug:
parcel --help build frontend/src/*/*_index.html --public-url /static
creates a html with non existent js:
<script src="/static/c1da89634367459316bb0791186cb047.js">
while
parcel --help build frontend/src/*/*_index.html --public-url ./static
creates html with wrong (relative) path
<script src="static/main.553dfdc2.js"></script>
Fixing the path by hand to
<script src="/static/main.553dfdc2.js"></script>
works
Most helpful comment
--no-hmrshould be a workaround if you don't need HMR.