Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep watching files imported in sass also when they have errors #134

Closed
Closed
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
18 changes: 15 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ var SassError = {
};
var resolveError = /Cannot resolve/;

var cachedIncludedFiles = [];

/**
* The sass-loader makes node-sass available to webpack modules.
*
* @param {string} content
* @returns {*}
*/

module.exports = function (content) {
var callback = this.async();
var isSync = typeof callback !== 'function';
Expand Down Expand Up @@ -148,15 +151,24 @@ module.exports = function (content) {
if (isSync) {
try {
result = sass.renderSync(opt);
addIncludedFilesToWebpack(result.stats.includedFiles);
cachedIncludedFiles = result.stats.includedFiles;
addIncludedFilesToWebpack(cachedIncludedFiles);
return result.css.toString();
} catch (err) {
if (err.file) {
cachedIncludedFiles.push(err.file);
}
addIncludedFilesToWebpack(cachedIncludedFiles);
formatSassError(err);
throw err;
}
}
sass.render(opt, function onRender(err, result) {
if (err) {
if (err.file) {
cachedIncludedFiles.push(err.file);
}
addIncludedFilesToWebpack(cachedIncludedFiles);
formatSassError(err);
callback(err);
return;
Expand All @@ -171,8 +183,8 @@ module.exports = function (content) {
} else {
result.map = null;
}

addIncludedFilesToWebpack(result.stats.includedFiles);
cachedIncludedFiles = result.stats.includedFiles;
addIncludedFilesToWebpack(cachedIncludedFiles);
callback(null, result.css.toString(), result.map);
});
};
Expand Down