diff --git a/index.js b/index.js index 150585c2..0c16011c 100644 --- a/index.js +++ b/index.js @@ -28,18 +28,26 @@ module.exports = function (content) { // output compressed by default opt.outputStyle = opt.outputStyle || 'compressed'; opt.stats = {}; - - // mark dependencies - var graph = sassGraph.parseFile(this.resourcePath, {loadPaths: opt.includePaths}); - graph.visitDescendents(this.resourcePath, function (imp) { - this.addDependency(imp); - }.bind(this)); + + var loadPaths = opt.includePaths; + var markDependencies = function () { + try { + var graph = sassGraph.parseFile(this.resourcePath, {loadPaths: loadPaths}); + graph.visitDescendents(this.resourcePath, function (imp) { + this.addDependency(imp); + }.bind(this)); + } catch(err) { + this.emitError(err); + } + }.bind(this); opt.success = function (css) { + markDependencies(); callback(null, css); }.bind(this); opt.error = function (err) { + markDependencies(); this.emitError(err); callback(err); }.bind(this); diff --git a/package.json b/package.json index 9638d635..ab29a0ca 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": { "loader-utils": "~0.2.2", "node-sass": "^1.2.2", - "sass-graph": "^0.1.2" + "sass-graph": "git+https://github.com/lox/sass-graph.git#3a17328" }, "devDependencies": { "mocha": "^2.0.1", diff --git a/test/index.test.js b/test/index.test.js index 697ebf3e..c61ad252 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -67,4 +67,7 @@ describe('sass-loader', function () { test('should pass the include paths to node-sass', 'include-paths', 'includePaths[]=' + path.resolve(__dirname, './sass/another') + '&' + 'includePaths[]=' + path.resolve(__dirname, './scss/another')); + + // Test for issue: https://github.com/jtangelder/sass-loader/issues/32 + test('should pass with multiple imports', 'multiple-imports') }); diff --git a/test/sass/multiple-imports.sass b/test/sass/multiple-imports.sass new file mode 100644 index 00000000..fb3e3576 --- /dev/null +++ b/test/sass/multiple-imports.sass @@ -0,0 +1 @@ +@import "language", "another/module" \ No newline at end of file diff --git a/test/scss/multiple-imports.scss b/test/scss/multiple-imports.scss new file mode 100644 index 00000000..fd7b4506 --- /dev/null +++ b/test/scss/multiple-imports.scss @@ -0,0 +1 @@ +@import "language", "another/module"; \ No newline at end of file