diff --git a/lib/importsToResolve.js b/lib/importsToResolve.js index 7cf79627..d4b75df0 100644 --- a/lib/importsToResolve.js +++ b/lib/importsToResolve.js @@ -3,7 +3,7 @@ const path = require("path"); const utils = require("loader-utils"); -const matchModuleImport = /^~([^\/]+|@[^\/]+[\/][^\/]+)$/g; +const matchModuleImport = /^~([^\/]+|@[^\/]+[\/][^\/]+)$/; /** * When libsass tries to resolve an import, it uses a special algorithm. diff --git a/test/index.test.js b/test/index.test.js index e7f08561..a0cf7bd6 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -205,7 +205,7 @@ describe("sass-loader", () => { sourceMap.should.not.have.property("file"); sourceMap.should.have.property("sourceRoot", fakeCwd); // This number needs to be updated if imports.scss or any dependency of that changes - sourceMap.sources.should.have.length(11); + sourceMap.sources.should.have.length(13); sourceMap.sources.forEach(sourcePath => fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath)) ); diff --git a/test/node_modules/module b/test/node_modules/module new file mode 100644 index 00000000..73929eee --- /dev/null +++ b/test/node_modules/module @@ -0,0 +1,3 @@ +.module { + background: hotpink; +} diff --git a/test/node_modules/other-module b/test/node_modules/other-module new file mode 100644 index 00000000..1efaed0b --- /dev/null +++ b/test/node_modules/other-module @@ -0,0 +1,3 @@ +.other-module { + background: hotpink; +} diff --git a/test/sass/imports.sass b/test/sass/imports.sass index cfc6b6bc..fc93a369 100644 --- a/test/sass/imports.sass +++ b/test/sass/imports.sass @@ -22,3 +22,7 @@ // See https://github.com/webpack-contrib/sass-loader/issues/556 /* @import util */ @import util +/* @import ~module */ +@import ~module +/* @import ~other-module */ +@import ~other-module diff --git a/test/scss/imports.scss b/test/scss/imports.scss index 5b316192..bd6736c9 100644 --- a/test/scss/imports.scss +++ b/test/scss/imports.scss @@ -23,4 +23,9 @@ } // The local util file should take precedence over Node's util module // See https://github.com/webpack-contrib/sass-loader/issues/556 +/* @import "util"; */ @import "util"; +/* @import "~module"; */ +@import "~module"; +/* @import "~other-module"; */ +@import "~other-module";