From 518cb66e730e5ef70ad9824e5669150a1b86bde3 Mon Sep 17 00:00:00 2001 From: jxcao Date: Mon, 11 Jun 2018 19:36:54 +0800 Subject: [PATCH] fix: when a package is installed using CNPM 'TypeError require(...) is not a function' occurs --- src/extractLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extractLoader.js b/src/extractLoader.js index c1d0740..63c546a 100644 --- a/src/extractLoader.js +++ b/src/extractLoader.js @@ -40,7 +40,7 @@ function extractLoader(content) { // If the required file is a css-loader helper, we just require it with node's require. // If the required file should be processed by a loader we do not touch it (even if it is a .js file). - if (/^[^!]*node_modules[/\\]css-loader[/\\].*\.js$/i.test(absPath)) { + if (/^[^!]*node_modules[/\\](_css-loader@[.\d]+@)*css-loader[/\\].*\.js$/i.test(absPath)) { // Mark the file as dependency so webpack's watcher is working for the css-loader helper. // Other dependencies are automatically added by loadModule() below this.addDependency(absPath);