From 121295f943f012d1cf26ea41d75d5bcce30ea20e Mon Sep 17 00:00:00 2001 From: Kaloyan Manolov Date: Fri, 26 Sep 2025 12:12:43 +0300 Subject: [PATCH 1/2] feat: allow for css module exceptions --- src/index.cjs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/index.cjs b/src/index.cjs index c241877..bbb33ac 100644 --- a/src/index.cjs +++ b/src/index.cjs @@ -39,7 +39,7 @@ class ScratchWebpackConfigBuilder { * @param {string|URL} [options.srcPath] The absolute path to the source files. Defaults to `src` under `rootPath`. * @param {boolean} [options.shouldSplitChunks] Whether to enable spliting code to chunks. */ - constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks }) { + constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks, cssModuleExceptions = [] }) { const isProduction = process.env.NODE_ENV === 'production'; const mode = isProduction ? 'production' : 'development'; @@ -184,6 +184,7 @@ class ScratchWebpackConfigBuilder { enableReact ? [ { test: /\.css$/, + exclude: cssModuleExceptions, use: [ { loader: 'style-loader' @@ -213,6 +214,25 @@ class ScratchWebpackConfigBuilder { } } ] + }, + { + test: cssModuleExceptions, + use: [ + 'style-loader', + 'css-loader', + { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: [ + 'postcss-import', + 'postcss-simple-vars', + 'autoprefixer' + ] + } + } + } + ] } ] : [] ), From 7a4836fe12cd916a060123a7468160343d4b1184 Mon Sep 17 00:00:00 2001 From: Ayshe Dzhindzhi Date: Tue, 30 Sep 2025 12:34:17 +0300 Subject: [PATCH 2/2] fix: add cssModuleExceptions as @param --- src/index.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.cjs b/src/index.cjs index bbb33ac..cded4a2 100644 --- a/src/index.cjs +++ b/src/index.cjs @@ -38,6 +38,7 @@ class ScratchWebpackConfigBuilder { * @param {string} [options.libraryName] The name of the library to build. Shorthand for `output.library.name`. * @param {string|URL} [options.srcPath] The absolute path to the source files. Defaults to `src` under `rootPath`. * @param {boolean} [options.shouldSplitChunks] Whether to enable spliting code to chunks. + * @param {RegExp[]} [options.cssModuleExceptions] Optional array of regex rules that exclude matching CSS files from CSS module scoping. */ constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks, cssModuleExceptions = [] }) { const isProduction = process.env.NODE_ENV === 'production';