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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel --public-url ./ doesn't support scripts and links in subfolders #2449

Closed
advename opened this issue Dec 21, 2018 · 11 comments
Closed

Comments

@advename
Copy link

advename commented Dec 21, 2018

πŸ› bug report

I have following file tree:

β”‚   index.html
β”‚
β”œβ”€β”€β”€donate
β”‚       step-1.html
β”‚       step-2.html
β”‚
β”œβ”€β”€β”€scripts
β”‚       main.js
β”‚
└───styles
        main.css

The step-1.html and step-2.html are both linking to the main.js and main.css. In order to get to that path I have to use ../scripts/main.js and ../styles/main.css to access them. But when bundling them with parcel using following command parcel build index.html --public-url ./ , parcel bundles the output as if they are in the same folder. Anchor tags, however, are working fine.

πŸŽ› Configuration (.babelrc, package.json, cli command)

Zero config

πŸ€” Expected Behavior

Parcel should bundle to the correct paths

😯 Current Behavior

Parcel bundles to the root path for scripts and links

πŸ’» Code Sample

A full working example can be seen here:
https:/advename/Parcel-error-example/tree/master

🌍 Your Environment

Software Version(s)
Parcel 1.9.7
Node 8.11.2
npm/Yarn 5.6.0
Operating System Windows 10 64-bit Pro
@kirillrogovoy
Copy link
Contributor

Is it a bug or a feature?

Parcel bundles all your Javascript and CSS into separate files and places them near the processed HTML file.

It replaces all the references in your script and link tags so that they point to the correct files.

So what's the original problem you're trying to solve? All you Javascript and CSS should be working just fine.


On a separate note, it's important to understand that the output bundles (e.g. index.css) or not 1:1 to the input assets.

You could have ten different <link> tags and you would still end up with just one output file.

@DeMoorJasper
Copy link
Member

If you require the same asset from 2 different places, parcel creates a shared bundle for both these files. Not sure why you wouldn’t want this though as it would save you or your company a bit of money and your users loading time. As there is only one bundle that needs to get cached at the cdn and user.

In Parcel 2 we’ve taken this a big step further with extracting shared assets into shared bundles. (As most applications share a couple libraries across various entrypoints)

Sent with GitHawk

@advename
Copy link
Author

It's not about feature or "best practice" in this case.
In the code sample that I've provided, you can clearly see in the dist that parcel links to <link rel="stylesheet" href="main.04aee6b8.css"> but since I'm using apache and this project is in a subfolder, well, the correct path should be <link rel="stylesheet" href="../main.04aee6b8.css">. The same goes for the script element.

@DeMoorJasper
Copy link
Member

@advename ow alright, will flag it as a bug again.

@mischnic
Copy link
Member

In the code sample that I've provided, you can clearly see in the dist that parcel links to <link rel="stylesheet" href="main.04aee6b8.css"> but since I'm using apache and this project is in a subfolder, well, the correct path should be <link rel="stylesheet" href="../main.04aee6b8.css">. The same goes for the script element.

That reminds me of #1801 / #2518

@hugojing
Copy link

Would someone like to tell us about the progress?

@yisar
Copy link

yisar commented May 11, 2019

I have the same problem. What can I do now?

@WireCrazii
Copy link

This bloody bug still exists.

@gswierczynski
Copy link

gswierczynski commented Jan 20, 2020

Is there a way to work around this?
I am using static-i18n to generate localized versions of html file.
I would like to have each language version in /<language_code>.
Unfortunately all parent ".." paths are ignored and output files in subdirectories reference assets without them.

@github-actions github-actions bot added the Stale Inactive issues label Jul 18, 2020
@alsoknownasdrew
Copy link

Any updates on this?

@github-actions github-actions bot removed the Stale Inactive issues label Jul 22, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 19, 2021
@github-actions github-actions bot closed this as completed Feb 2, 2021
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

9 participants