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

URL rewriting fails when invoking parcel build with multiple entries #2407

Closed
davepeck opened this issue Dec 13, 2018 · 3 comments
Closed

URL rewriting fails when invoking parcel build with multiple entries #2407

davepeck opened this issue Dec 13, 2018 · 3 comments

Comments

@davepeck
Copy link

davepeck commented Dec 13, 2018

馃悰 bug report

When using parcel build with multiple entries, URL rewriting can fail.

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

馃 Expected Behavior

Given the following directory structure:

project/
project/src/
project/src/css/
project/src/css/example.scss
project/src/images/image.png
project/src/js/index.js

Full content of example.scss:

body {
  background-image: url("../images/image.png");
}

image.png is arbitrary and index.js is empty.

Running parcel build src/css/example.scss src/js/index.js from the top-level project/ directory results in a dist/ directory with the following contents:

dist/image.72099d14.png
dist/js/index.js
dist/css/example.map
dist/css/example.css

That's fine, but dist/css/example.css should contain a valid url(...) reference:

body{background-image:url(../image.72099d14.png)}

馃槸 Current Behavior

Unfortunately, dist/css/example.css contains an invalid url(...) reference:

body{background-image:url(image.72099d14.png)}

Note the lack of ../ -- a bug.

Alternatively, I suppose we could argue that the bug is actually the fact that example.css is placed in the dist/css/ subdirectory, rather than directly in the dist/ directory. If we placed example.css and index.js in the top-level dist/ instead, then we'd have something equivalent to running parcel build twice, once for each entry.

By the way, this isn't a requirement, but my expectation (as a first time parcel user) was that dist/ would actually contain an images/ subdirectory in this case, and the actual link in dist/css/example.css would be:

body{background-image:url(../images/image.72099d14.png)}

馃拋 Possible Solution

馃敠 Context

馃捇 Code Sample

See attachment for example project directory.

project.zip

馃實 Your Environment

parcel version 1.10.3

@davepeck
Copy link
Author

If someone could comment which direction the bug actually is (either the URL is wrong, or the placement of files in dist/ is wrong), I might be interested in looking under Parcel's hood to see what fixing this would take. Thanks!

@kirillrogovoy
Copy link
Contributor

Or the third option could be to use absolute paths:

body{background-image:url(/image.72099d14.png)}

should work just fine too.

Would be great to hear @DeMoorJasper's opinion on this issue.

@mischnic
Copy link
Member

This was fixed in #2518

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

4 participants