From 50bcadfff3c2b38efb5f5598dd67462a4724cc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20Jos=C3=A9povic?= Date: Tue, 31 Oct 2023 10:39:01 -0400 Subject: [PATCH 1/2] Make Webpack RegEx stricter --- packages/webpack-configs/src/build.ts | 10 +++++----- packages/webpack-configs/src/dev.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/webpack-configs/src/build.ts b/packages/webpack-configs/src/build.ts index 02b0e5a1..d582a4ee 100644 --- a/packages/webpack-configs/src/build.ts +++ b/packages/webpack-configs/src/build.ts @@ -157,21 +157,21 @@ export function defineBuildConfig(swcConfig: SwcConfig, options: DefineBuildConf module: { rules: [ { - test: /\.(js|jsx|ts|tsx)/i, + test: /\.(js|jsx|ts|tsx)$/i, exclude: /node_modules/, loader: require.resolve("swc-loader"), options: swcConfig }, { // https://stackoverflow.com/questions/69427025/programmatic-webpack-jest-esm-cant-resolve-module-without-js-file-exten - test: /\.js/i, + test: /\.js$/i, include: /node_modules/, resolve: { fullySpecified: false } }, { - test: /\.css/i, + test: /\.css$/i, use: [ { loader: MiniCssExtractPlugin.loader }, { @@ -188,11 +188,11 @@ export function defineBuildConfig(swcConfig: SwcConfig, options: DefineBuildConf ] }, { - test: /\.svg/i, + test: /\.svg$/i, loader: require.resolve("@svgr/webpack") }, { - test: /\.(png|jpe?g|gif)/i, + test: /\.(png|jpe?g|gif)$/i, type: "asset/resource" }, ...moduleRules diff --git a/packages/webpack-configs/src/dev.ts b/packages/webpack-configs/src/dev.ts index c80f44ce..f9f3f877 100644 --- a/packages/webpack-configs/src/dev.ts +++ b/packages/webpack-configs/src/dev.ts @@ -174,21 +174,21 @@ export function defineDevConfig(swcConfig: SwcConfig, options: DefineDevConfigOp module: { rules: [ { - test: /\.(js|jsx|ts|tsx)/i, + test: /\.(js|jsx|ts|tsx)$/i, exclude: /node_modules/, loader: require.resolve("swc-loader"), options: trySetSwcFastRefresh(swcConfig, fastRefresh !== false) }, { // https://stackoverflow.com/questions/69427025/programmatic-webpack-jest-esm-cant-resolve-module-without-js-file-exten - test: /\.js/i, + test: /\.js$/i, include: /node_modules/, resolve: { fullySpecified: false } }, { - test: /\.css/i, + test: /\.css$/i, use: [ { loader: require.resolve("style-loader") }, { @@ -205,11 +205,11 @@ export function defineDevConfig(swcConfig: SwcConfig, options: DefineDevConfigOp ] }, { - test: /\.svg/i, + test: /\.svg$/i, loader: require.resolve("@svgr/webpack") }, { - test: /\.(png|jpe?g|gif)/i, + test: /\.(png|jpe?g|gif)$/i, type: "asset/resource" }, ...moduleRules From 5435dc7cb8e9d146b0c49e14836d0396eba69941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20Jos=C3=A9povic?= Date: Tue, 31 Oct 2023 11:55:11 -0400 Subject: [PATCH 2/2] Add changesets --- .changeset/tough-panthers-do.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tough-panthers-do.md diff --git a/.changeset/tough-panthers-do.md b/.changeset/tough-panthers-do.md new file mode 100644 index 00000000..2c9bfb65 --- /dev/null +++ b/.changeset/tough-panthers-do.md @@ -0,0 +1,5 @@ +--- +"@workleap/webpack-configs": patch +--- + +Fix file extension RegEx rules being too lenient