From d4a74b7e4157259437e1912bd0d68d0092f462ea Mon Sep 17 00:00:00 2001 From: Junjia Ni Date: Fri, 26 Aug 2016 22:11:35 +0800 Subject: [PATCH] fix the error of loading loader on windows Writing {include: __dirname + '/web-src'} on windows will meet the problem: You may need an appropriate loader to handle this file type which causes that the babel loader doesn't work. It is a good way to unify the slash on windows. --- lib/LoadersList.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/LoadersList.js b/lib/LoadersList.js index a5d7eb3..d2590a4 100644 --- a/lib/LoadersList.js +++ b/lib/LoadersList.js @@ -2,6 +2,8 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ +var OS = require('os'); + function LoadersList(list) { this.list = list || []; this.list.forEach(function(element) { @@ -19,6 +21,7 @@ function regExpAsMatcher(regExp) { function asMatcher(test) { if(typeof test === "string") { + test = /windows/i.test(OS.type()) ? test.split('/').join('\\') : test; return regExpAsMatcher(new RegExp("^"+test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"))); } else if(typeof test === "function") { return test; @@ -93,4 +96,4 @@ LoadersList.prototype.matchObject = function matchObject(str, obj) { if(obj.exclude) if(this.matchPart(str, obj.exclude)) return false; return true; -}; \ No newline at end of file +};