diff --git a/index.js b/index.js index 325d0f1d..cca07cde 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,7 @@ var SassError = { }; // libsass uses this precedence when importing files without extension +var slice = Array.prototype.slice; var extPrecedence = ['.scss', '.sass', '.css']; var matchCss = /\.css$/; @@ -409,7 +410,13 @@ function getLoaderConfig(loaderContext) { function proxyCustomImporters(importer, resourcePath) { return [].concat(importer).map(function (importer) { return function (url, prev, done) { - return importer(url, prev === 'stdin' ? resourcePath : prev, done); + var args = slice.call(arguments); + + if (args[1] === 'stdin') { + args[1] = resourcePath; + } + + return importer.apply(this, args); }; }); } diff --git a/test/tools/customImporter.js b/test/tools/customImporter.js index c607d4ba..4fb96429 100644 --- a/test/tools/customImporter.js +++ b/test/tools/customImporter.js @@ -3,8 +3,13 @@ var should = require('should'); function customImporter(path, prev) { + /*jshint validthis: true */ + path.should.equal('import-with-custom-logic'); prev.should.match(/(sass|scss)[/\\]custom-importer\.(scss|sass)/); + + this.should.have.property('options'); + return customImporter.returnValue; } customImporter.returnValue = {