Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$/;

Expand Down Expand Up @@ -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);
};
});
}
5 changes: 5 additions & 0 deletions test/tools/customImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down