Skip to content

Correctly build dependency URLs (for CSS)#2740

Merged
devongovett merged 2 commits into
masterfrom
relative-css
Mar 12, 2019
Merged

Correctly build dependency URLs (for CSS)#2740
devongovett merged 2 commits into
masterfrom
relative-css

Conversation

@mischnic

@mischnic mischnic commented Mar 7, 2019

Copy link
Copy Markdown
Member

↪️ Pull Request

Fixes #2736
Fix underlying issue and undo workaround of #2518

💻 Examples

Dependency URLs for bundles generated in subfolders would contain something like this <img src="/../logo_color.78fe8740.svg"> (not properly resolved).

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

Fix real core issue of #2518
budparr pushed a commit to theNewDynamic/thenewdynamic.org that referenced this pull request Mar 8, 2019
Parcel parcel-bundler/parcel#2740

parcel-bundler/parcel#2736

also removed --experimental-scope-hoisting until upgrade works

@DeMoorJasper DeMoorJasper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing

@mischnic

mischnic commented Mar 8, 2019

Copy link
Copy Markdown
Member Author

In some places absolute urls are used (with the publicURL) and in others a relative url. Should the absolute url be used everywhere? (That's why the tests are failing)

@font-face {
  font-family: "Test";
  src: url("/test.80d5c592.woff2") format("woff2");
  /* vs */
  src: url("test.80d5c592.woff2") format("woff2");
}

@DeMoorJasper

DeMoorJasper commented Mar 8, 2019

Copy link
Copy Markdown
Member

@mischnic I think they should both be possible, not sure what the behaviour should be though.
I think absolute paths should work like they do everywhere in Parcel. (same for ~node_module and ~/ paths, although those are currently not supported, and not sure if we should even support that)

@devongovett

Copy link
Copy Markdown
Member

Why do we need to switch to absolute paths for CSS? One of the nice things about using relative paths is that you can move the base directory around where you deploy and it still works.

@mischnic

Copy link
Copy Markdown
Member Author

Why do we need to switch to absolute paths for CSS? One of the nice things about using relative paths is that you can move the base directory around where you deploy and it still works.

With the current master, there are some cases where the paths somehow don't work: e.g. #2758 and #2736

Apart from that, sometimes Parcel uses a relative (this case) and sometimes a absolute path (with publicURL, e.g. in html url dependencies)

@devongovett

Copy link
Copy Markdown
Member

I think we can probably still use the relative path for CSS, but it needs to be set here instead of in replaceBundleNames:

parsed.pathname = this.options.parser
.getAsset(resolved, this.options)
.generateBundleName();

@devongovett

Copy link
Copy Markdown
Member

Probably should also add a test for #2736 as well.

@rhurstdialpad

Copy link
Copy Markdown
Contributor

When can we get a patch release on this? We need this ASAP at Dialpad.

@mischnic

Copy link
Copy Markdown
Member Author

When can we get a patch release on this? We need this ASAP at Dialpad.

This is already released as 1.12.1.

@rhurstdialpad

Copy link
Copy Markdown
Contributor

@mischnic @devongovett @DeMoorJasper Excellent, thanks guys. If you're ever in Vancouver, beers on me 🍻

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect svg filepath

4 participants