Skip to content

Commit

Permalink
fix sass importer, closed #78
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 27, 2018
1 parent d65dd08 commit e7b435d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/sass-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default {
data: code,
indentedSyntax: /\.sass$/.test(this.id),
sourceMap: this.sourceMap,
importer: [(url, prev, done) => {
if (!moduleRe.test(url)) return done({ file: prev })
importer: [(url, importer, done) => {
if (!moduleRe.test(url)) return done({ file: url })

resolve(url.slice(1), {
basedir: path.dirname(this.id),
basedir: path.dirname(importer),
extensions: ['.scss', '.sass', '.css']
}, (err, id) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function styleInject(css, ref) {
}
}
var css = \\".a {\\\\n color: pink; }\\\\n\\\\n.b {\\\\n color: red; }\\\\n\\\\n.c {\\\\n color: black; }\\\\n\\";
var css = \\".a {\\\\n color: pink; }\\\\n\\\\n.b {\\\\n color: red; }\\\\n\\\\n.c {\\\\n color: black; }\\\\n\\\\n.foo {\\\\n color: magenta; }\\\\n\\";
styleInject(css);
"
`;
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/sass-import/foo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo {
color: magenta;
}
1 change: 1 addition & 0 deletions test/fixtures/sass-import/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "~foo/bar/a";
@import "~foo/bar/b";
@import "~foo/bar/c";
@import "foo.scss";

0 comments on commit e7b435d

Please sign in to comment.