Skip to content

Commit fd6be1f

Browse files
author
Chris Fitzgerald
committed
Use resoucePath for custom importers
Fixes #234
1 parent 11aaf06 commit fd6be1f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,13 @@ module.exports = function (content) {
245245
}
246246

247247
// Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s.
248-
sassOptions.importer = sassOptions.importer ? [].concat(sassOptions.importer) : [];
248+
sassOptions.importer = sassOptions.importer ? [].concat(sassOptions.importer).map(function(importer) {
249+
return function(url, prev, done) {
250+
return importer(url, prev === 'stdin' ? resourcePath : prev, done);
251+
};
252+
})
253+
: []
254+
;
249255
sassOptions.importer.push(getWebpackImporter());
250256

251257
// `node-sass` uses `includePaths` to resolve `@import` paths. Append the currently processed file.

test/tools/customImporter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
var should = require('should');
44

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

0 commit comments

Comments
 (0)