Skip to content

Commit 2a6bbc5

Browse files
committed
Fix non file scheme in SASS
Fixes #10019
1 parent 4a297f7 commit 2a6bbc5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/core/integration-tests/test/sass.js

+26
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,30 @@ describe('sass', function () {
399399
inputFS: overlayFS,
400400
});
401401
});
402+
403+
it('should support npm scheme', async function () {
404+
const dir = path.join(__dirname, 'sass-extensions');
405+
overlayFS.mkdirp(dir);
406+
407+
await fsFixture(overlayFS, dir)`
408+
index.js:
409+
import './main.scss';
410+
411+
main.scss:
412+
@use 'npm:test' as test;
413+
414+
node_modules/test/package.json:
415+
{ "name": "test" }
416+
417+
node_modules/test/_index.scss:
418+
@use 'other';
419+
420+
node_modules/test/_other.scss:
421+
.foo { color: red }
422+
`;
423+
424+
await bundle(path.join(dir, '/index.js'), {
425+
inputFS: overlayFS,
426+
});
427+
});
402428
});

packages/transformers/sass/src/modern.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function resolvePathImporter({
9898
let containingPath = containingUrl
9999
? fileURLToPath(containingUrl)
100100
: asset.filePath;
101-
if (!containingUrl) {
101+
if (!containingUrl && url.startsWith('file:')) {
102102
// If containingUrl is not provided, then url should be an absolute file:/// URL.
103103
let filePath = fileURLToPath(url);
104104
url = path.relative(path.dirname(containingPath), filePath);

0 commit comments

Comments
 (0)