Skip to content

Commit

Permalink
Fix extension and sync error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranstrom committed Jan 23, 2017
1 parent d4c9463 commit f545999
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@ exports.extractSync = (rendered, { compileOptions = {} } = {}) => {
extractionCompileOptions.filename = entryFilename;
extractionCompileOptions.data = extractionMap[entryFilename].injectedData;
extractionCompileOptions.importer = function(url, prev) {
let absolutePath = path.join(path.dirname(prev), url);
if(path.extname(absolutePath) !== '.scss') {
absolutePath += '.scss';
try {
let absolutePath = path.join(path.dirname(prev), url);
let extension = path.extname(prev);

// Ensure import directive path include extension
if(path.extname(absolutePath) !== extension) {
absolutePath += extension;
}

return { file: absolutePath, contents: extractionMap[absolutePath].injectedData };
} catch(err) {
// note: importer has to return any error
return err;
}
return { file: absolutePath, contents: extractionMap[absolutePath].injectedData };
}

sass.renderSync(extractionCompileOptions);
Expand Down

0 comments on commit f545999

Please sign in to comment.