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
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ module.exports = function (content) {
}

// Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s.
sassOptions.importer = sassOptions.importer ? [].concat(sassOptions.importer) : [];
sassOptions.importer = sassOptions.importer ? [].concat(sassOptions.importer).map(function(importer) {
return function(url, prev, done) {
return importer(url, prev === 'stdin' ? resourcePath : prev, done);
};
})
: []
;
sassOptions.importer.push(getWebpackImporter());

// `node-sass` uses `includePaths` to resolve `@import` paths. Append the currently processed file.
Expand Down
3 changes: 2 additions & 1 deletion test/tools/customImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

var should = require('should');

function customImporter(path) {
function customImporter(path, prev) {
path.should.equal('import-with-custom-logic');
prev.match(process.cwd() + '/test/(sass|scss)/custom-importer.(scss|sass)').should.not.equal(null);
return customImporter.returnValue;
}
customImporter.returnValue = {
Expand Down