Skip to content

Commit 04cb1ef

Browse files
committed
Merge pull request #35 from akiran/master
Fixed import parsing failures
2 parents 9310451 + 0443600 commit 04cb1ef

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,26 @@ module.exports = function (content) {
2828
// output compressed by default
2929
opt.outputStyle = opt.outputStyle || 'compressed';
3030
opt.stats = {};
31-
32-
// mark dependencies
33-
var graph = sassGraph.parseFile(this.resourcePath, {loadPaths: opt.includePaths});
34-
graph.visitDescendents(this.resourcePath, function (imp) {
35-
this.addDependency(imp);
36-
}.bind(this));
31+
32+
var loadPaths = opt.includePaths;
33+
var markDependencies = function () {
34+
try {
35+
var graph = sassGraph.parseFile(this.resourcePath, {loadPaths: loadPaths});
36+
graph.visitDescendents(this.resourcePath, function (imp) {
37+
this.addDependency(imp);
38+
}.bind(this));
39+
} catch(err) {
40+
this.emitError(err);
41+
}
42+
}.bind(this);
3743

3844
opt.success = function (css) {
45+
markDependencies();
3946
callback(null, css);
4047
}.bind(this);
4148

4249
opt.error = function (err) {
50+
markDependencies();
4351
this.emitError(err);
4452
callback(err);
4553
}.bind(this);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"loader-utils": "~0.2.2",
2323
"node-sass": "^1.2.2",
24-
"sass-graph": "^0.1.2"
24+
"sass-graph": "git+https://github.com/lox/sass-graph.git#3a17328"
2525
},
2626
"devDependencies": {
2727
"mocha": "^2.0.1",

test/index.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ describe('sass-loader', function () {
6767
test('should pass the include paths to node-sass', 'include-paths',
6868
'includePaths[]=' + path.resolve(__dirname, './sass/another') + '&' +
6969
'includePaths[]=' + path.resolve(__dirname, './scss/another'));
70+
71+
// Test for issue: https://github.com/jtangelder/sass-loader/issues/32
72+
test('should pass with multiple imports', 'multiple-imports')
7073
});

test/sass/multiple-imports.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "language", "another/module"

test/scss/multiple-imports.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "language", "another/module";

0 commit comments

Comments
 (0)