Skip to content

Commit

Permalink
Fix non file scheme in SASS
Browse files Browse the repository at this point in the history
Fixes #10019
  • Loading branch information
devongovett committed Nov 25, 2024
1 parent 4a297f7 commit 2a6bbc5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/core/integration-tests/test/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,30 @@ describe('sass', function () {
inputFS: overlayFS,
});
});

it('should support npm scheme', async function () {
const dir = path.join(__dirname, 'sass-extensions');
overlayFS.mkdirp(dir);

await fsFixture(overlayFS, dir)`
index.js:
import './main.scss';
main.scss:
@use 'npm:test' as test;
node_modules/test/package.json:
{ "name": "test" }
node_modules/test/_index.scss:
@use 'other';
node_modules/test/_other.scss:
.foo { color: red }
`;

await bundle(path.join(dir, '/index.js'), {
inputFS: overlayFS,
});
});
});
2 changes: 1 addition & 1 deletion packages/transformers/sass/src/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function resolvePathImporter({
let containingPath = containingUrl
? fileURLToPath(containingUrl)
: asset.filePath;
if (!containingUrl) {
if (!containingUrl && url.startsWith('file:')) {
// If containingUrl is not provided, then url should be an absolute file:/// URL.
let filePath = fileURLToPath(url);
url = path.relative(path.dirname(containingPath), filePath);
Expand Down

0 comments on commit 2a6bbc5

Please sign in to comment.