From 147ca61e4614cc7353d5f723effd5725fe1a5d9a Mon Sep 17 00:00:00 2001 From: endaaman Date: Fri, 31 Jul 2015 20:42:17 +0900 Subject: [PATCH 1/3] Add included files to webpack also when build failed --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b4d901c3..83e1da02 100644 --- a/index.js +++ b/index.js @@ -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'; @@ -148,15 +151,18 @@ 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) { + addIncludedFilesToWebpack(cachedIncludedFiles); formatSassError(err); throw err; } } sass.render(opt, function onRender(err, result) { if (err) { + addIncludedFilesToWebpack(cachedIncludedFiles); formatSassError(err); callback(err); return; @@ -171,8 +177,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); }); }; From 641f92bbb3241d0dfe0b652e0c7baeed638f6f8d Mon Sep 17 00:00:00 2001 From: endaaman Date: Fri, 31 Jul 2015 21:44:47 +0900 Subject: [PATCH 2/3] Add file with error to webpack when errored --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 83e1da02..ec3d444b 100644 --- a/index.js +++ b/index.js @@ -155,6 +155,9 @@ module.exports = function (content) { addIncludedFilesToWebpack(cachedIncludedFiles); return result.css.toString(); } catch (err) { + if (err.file) { + cachedIncludedFiles.push(err.file); + } addIncludedFilesToWebpack(cachedIncludedFiles); formatSassError(err); throw err; @@ -162,6 +165,10 @@ module.exports = function (content) { } sass.render(opt, function onRender(err, result) { if (err) { + console.log(err); + if (err.file) { + cachedIncludedFiles.push(err.file); + } addIncludedFilesToWebpack(cachedIncludedFiles); formatSassError(err); callback(err); From 43f9742930d6213c3255886c00700fd8dddd0399 Mon Sep 17 00:00:00 2001 From: endaaman Date: Fri, 31 Jul 2015 22:08:40 +0900 Subject: [PATCH 3/3] Remove logging line --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index ec3d444b..f1121b3c 100644 --- a/index.js +++ b/index.js @@ -165,7 +165,6 @@ module.exports = function (content) { } sass.render(opt, function onRender(err, result) { if (err) { - console.log(err); if (err.file) { cachedIncludedFiles.push(err.file); }