From 92ea8b5d767b9f4c9435d9e95ce7ad3d069c9283 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Jul 2018 12:31:25 +0200 Subject: [PATCH] Fix regular expressions on Windows (Fixes #3) --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 026e3992..6b92702c 100644 --- a/index.js +++ b/index.js @@ -145,7 +145,7 @@ function createPlugins(workers, outputPath) { function createContextPlugin(filePath, contextPaths) { return new webpack.ContextReplacementPlugin( - new RegExp(`^${path.dirname(filePath)}$`), + new RegExp(`^${path.dirname(filePath).replace(/[\/\\]/g, '(/|\\\\)')}$`), '', contextPaths ); @@ -154,7 +154,7 @@ function createContextPlugin(filePath, contextPaths) { function createIgnoreImportsPlugin(targetPath, ignoredModules) { return new webpack.IgnorePlugin( new RegExp(`^(${ignoredModules.map((id) => `(${id})`).join('|')})$`), - new RegExp(`^${path.dirname(targetPath)}$`) + new RegExp(`^${path.dirname(targetPath).replace(/[\/\\]/g, '(/|\\\\)')}$`) ); }