From b749c2d45a91de51adec307838af2acafc2033d3 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Thu, 4 Jun 2020 19:42:41 +0200 Subject: [PATCH] Fix flash from url on windows Changelog-entry: Fix flash from url on windows Change-type: patch --- webpack.config.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webpack.config.ts b/webpack.config.ts index 3168b0c7..14a51c98 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -96,11 +96,15 @@ interface ReplacementRule { replace: string | (() => string); } +function slashOrAntislash(pattern: RegExp): RegExp { + return new RegExp(pattern.source.replace(/\\\//g, '(\\/|\\\\)')); +} + function replace(test: RegExp, ...replacements: ReplacementRule[]) { return { loader: 'string-replace-loader', // Handle windows path separators - test: new RegExp(test.source.replace(/\\\//g, '(\\/|\\\\)')), + test: slashOrAntislash(test), options: { multiple: replacements.map((r) => ({ ...r, strict: true })) }, }; } @@ -223,7 +227,7 @@ const commonConfig = { // Force axios to use http.js, not xhr.js as we need stream support // (it's package.json file replaces http with xhr for browser targets). new NormalModuleReplacementPlugin( - /node_modules\/axios\/lib\/adapters\/xhr\.js/, + slashOrAntislash(/node_modules\/axios\/lib\/adapters\/xhr\.js/), './http.js', ), ],