Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel output refers to a nonexistent js file, when referring to other html file #2791

Open
ariel42 opened this issue Mar 13, 2019 · 5 comments

Comments

@ariel42
Copy link

ariel42 commented Mar 13, 2019

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.

馃帥 Configuration (.babelrc, package.json, cli command)

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

馃 Expected Behavior

Valid output of index.html, that referes correctly to docs/terms.html

馃槸 Current Behavior

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.

馃拋 Possible Solution

Refer correctly to the generated js file.

馃敠 Context

Testing Parcel for building static site.

馃捇 Code Sample

Provided above.

馃實 Your Environment

Software Version(s)
Parcel CLI 1.12.1
Node 10.13.0
npm/Yarn 6.4.1
Operating System Windows 10
@LukBukkit
Copy link

Same problem with Parcel 1.12.3, but it works in version 1.9.7

@Alamantus
Copy link

Alamantus commented Jun 3, 2019

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.

Alamantus pushed a commit to Alamantus/Lexiconga that referenced this issue Jun 3, 2019
@mischnic
Copy link
Member

mischnic commented Jun 4, 2019

--no-hmr should be a workaround if you don't need HMR.

Alamantus added a commit to Alamantus/Lexiconga that referenced this issue Jul 11, 2019
Alamantus added a commit to Alamantus/Lexiconga that referenced this issue Jul 11, 2019
@Minobi
Copy link

Minobi commented Aug 23, 2019

parcel build index.html --public-url ./ solved referring problem for me with Parcel 1.12.3

@qt1
Copy link

qt1 commented Sep 7, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants