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

Fix absolute path importing in sass #2432

Merged
merged 11 commits into from
Feb 17, 2019
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.b {
color: red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '/b.scss';

.a {
color: blue;
}
18 changes: 18 additions & 0 deletions packages/core/integration-tests/test/sass.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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