Skip to content

Commit

Permalink
Use resoucePath for custom importers
Browse files Browse the repository at this point in the history
Fixes #234
  • Loading branch information
Chris Fitzgerald committed Aug 10, 2016
1 parent 11aaf06 commit fd6be1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit fd6be1f

Please sign in to comment.