Skip to content

Commit

Permalink
fix: make webpack RegEx stricter (#167)
Browse files Browse the repository at this point in the history
* Make Webpack RegEx stricter

* Add changesets
  • Loading branch information
tjosepo authored Oct 31, 2023
1 parent 786c2aa commit 55e0bd4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-panthers-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workleap/webpack-configs": patch
---

Fix file extension RegEx rules being too lenient
10 changes: 5 additions & 5 deletions packages/webpack-configs/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
{
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/webpack-configs/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") },
{
Expand All @@ -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
Expand Down

0 comments on commit 55e0bd4

Please sign in to comment.