diff --git a/src/assets/SASSAsset.js b/src/assets/SASSAsset.js index a05280665e4..69e6e71e7f6 100644 --- a/src/assets/SASSAsset.js +++ b/src/assets/SASSAsset.js @@ -43,6 +43,11 @@ class SASSAsset extends Asset { opts.importer.push((url, prev, done) => { let resolved; try { + if (!/^(~|\.\/|\/)/.test(url)) { + url = './' + url; + } else if (!/^(~\/|\.\/|\/)/.test(url)) { + url = url.substring(1); + } resolved = syncPromise( resolver.resolve(url, prev === 'stdin' ? this.name : prev) ).path; diff --git a/test/integration/sass-advanced-import/bar.sass b/test/integration/sass-advanced-import/bar.sass new file mode 100644 index 00000000000..4744ff20c5a --- /dev/null +++ b/test/integration/sass-advanced-import/bar.sass @@ -0,0 +1,2 @@ +.bar + color: green; diff --git a/test/integration/sass-advanced-import/foo.sass b/test/integration/sass-advanced-import/foo.sass new file mode 100644 index 00000000000..311ad75d985 --- /dev/null +++ b/test/integration/sass-advanced-import/foo.sass @@ -0,0 +1,2 @@ +.foo + color: blue; diff --git a/test/integration/sass-advanced-import/hello.sass b/test/integration/sass-advanced-import/hello.sass deleted file mode 100644 index f300bab3e65..00000000000 --- a/test/integration/sass-advanced-import/hello.sass +++ /dev/null @@ -1,2 +0,0 @@ -.hello - color: blue; \ No newline at end of file diff --git a/test/integration/sass-advanced-import/index.sass b/test/integration/sass-advanced-import/index.sass index f18b337187a..7e111ca909e 100644 --- a/test/integration/sass-advanced-import/index.sass +++ b/test/integration/sass-advanced-import/index.sass @@ -1,5 +1,6 @@ -@import '~/hello.sass'; +@import '~/foo'; +@import '~/bar.sass'; .index background: #ffffff; - color: #000000; \ No newline at end of file + color: #000000; diff --git a/test/integration/scss-import/bar.scss b/test/integration/scss-import/bar.scss new file mode 100644 index 00000000000..c3afb025398 --- /dev/null +++ b/test/integration/scss-import/bar.scss @@ -0,0 +1,5 @@ +$bar: #f8a93b; + +.bar { + color: $bar; +} diff --git a/test/integration/scss-import/base.scss b/test/integration/scss-import/base.scss deleted file mode 100644 index a90b8053d69..00000000000 --- a/test/integration/scss-import/base.scss +++ /dev/null @@ -1,5 +0,0 @@ -$base: #f938ab; - -.base { - color: $base; -} diff --git a/test/integration/scss-import/foo.scss b/test/integration/scss-import/foo.scss new file mode 100644 index 00000000000..96a9ecdb19d --- /dev/null +++ b/test/integration/scss-import/foo.scss @@ -0,0 +1,5 @@ +$foo: #f938ab; + +.foo { + color: $foo; +} diff --git a/test/integration/scss-import/index.scss b/test/integration/scss-import/index.scss index 54d9f69b819..b45c8976326 100644 --- a/test/integration/scss-import/index.scss +++ b/test/integration/scss-import/index.scss @@ -1,5 +1,7 @@ -@import './base.scss'; +@import 'foo'; +@import './bar.scss'; .index { - color: $base; + color: $foo; + background-color: $bar; } diff --git a/test/sass.js b/test/sass.js index 170698dcbe3..9be0fde884f 100644 --- a/test/sass.js +++ b/test/sass.js @@ -79,7 +79,8 @@ describe('sass', function() { let css = fs.readFileSync(__dirname + '/dist/index.css', 'utf8'); assert(css.includes('.index')); - assert(css.includes('.base')); + assert(css.includes('.foo')); + assert(css.includes('.bar')); }); it('should support requiring empty scss files', async function() { @@ -183,7 +184,10 @@ describe('sass', function() { assets: ['index.sass'] }); - let css = fs.readFileSync(__dirname + '/dist/index.css', 'utf8'); - assert(css.includes('color: blue;')); + let css = fs + .readFileSync(__dirname + '/dist/index.css', 'utf8') + .replace(/\s+/g, ' '); + assert(css.includes('.foo { color: blue;')); + assert(css.includes('.bar { color: green;')); }); });