Skip to content

Commit

Permalink
Fix absolute path importing in sass (#2432)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeMoorJasper authored and devongovett committed Feb 17, 2019
1 parent c2760fd commit 31bd420
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
@@ -0,0 +1,3 @@
.b {
color: red;
}
@@ -0,0 +1,5 @@
@import '/b.scss';

.a {
color: blue;
}
18 changes: 18 additions & 0 deletions packages/core/integration-tests/test/sass.js
Expand Up @@ -228,4 +228,22 @@ describe('sass', function() {
assert(css.includes('.foo { color: blue;'));
assert(css.includes('.bar { color: green;'));
});

it('should support absolute imports', async function() {
let b = await bundle(
path.join(__dirname, '/integration/scss-absolute-imports/style.scss')
);

await assertBundleTree(b, {
name: 'style.css',
assets: ['style.scss']
});

let css = await fs.readFile(
path.join(__dirname, '/dist/style.css'),
'utf8'
);
assert(css.includes('.a'));
assert(css.includes('.b'));
});
});
1 change: 1 addition & 0 deletions packages/core/parcel-bundler/src/assets/SASSAsset.js
Expand Up @@ -45,6 +45,7 @@ class SASSAsset extends Asset {
? opts.importer
: [opts.importer];
opts.importer.push((url, prev, done) => {
url = url.replace(/^file:\/\//, '');
url = parseCSSImport(url);
resolver
.resolve(url, prev === 'stdin' ? this.name : prev)
Expand Down

0 comments on commit 31bd420

Please sign in to comment.