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

bug/issue 1368 handle bundling of relative node_modules paths for CSS url paths #1369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/cli/src/plugins/resource/plugin-standard-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function bundleCss(body, sourceUrl, compilation, workingUrl) {
} else if (value.startsWith('/node_modules/')) {
// if it's a node modules shortcut alias, just use that
finalValue = value;
} else if (value.indexOf('../node_modules/') >= 0) {
// if it's a relative node_modules path, convert it to a shortcut alias
finalValue = `/${value.replace(/\.\.\//g, '')}`;
} else if (resolvedUrl.href.indexOf('/node_modules/') >= 0) {
// if we are deep in node_modules land, use resolution logic to figure out the specifier
const resolvedRoot = derivePackageRoot(resolvedUrl.href);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Build Greenwood With: ', function() {
before(async function() {
// this package has a known issue with import.meta.resolve
// in that it has no main, module, or exports so it has to be hoisted
// at least for this current version
// at least for this current version, as well as for testing relative ../node_modules references
// https://unpkg.com/browse/font-awesome@4.7.0/package.json
// https://github.com/FortAwesome/Font-Awesome/pull/19041
const fontAwesomePackageJson = await getDependencyFiles(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import url('/node_modules/@spectrum-web-components/styles/all-large-dark.css');
@import url('/node_modules/font-awesome/css/font-awesome.css');
@import url('../../node_modules/font-awesome/css/font-awesome.css');
Loading