Skip to content

Commit 5a35968

Browse files
authored
Merge pull request #105 from KManolov3/feature/uepr-331-allow-module-exceptions
feat: allow for css module exceptions
2 parents 58c7a65 + 7a4836f commit 5a35968

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/index.cjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class ScratchWebpackConfigBuilder {
3838
* @param {string} [options.libraryName] The name of the library to build. Shorthand for `output.library.name`.
3939
* @param {string|URL} [options.srcPath] The absolute path to the source files. Defaults to `src` under `rootPath`.
4040
* @param {boolean} [options.shouldSplitChunks] Whether to enable spliting code to chunks.
41+
* @param {RegExp[]} [options.cssModuleExceptions] Optional array of regex rules that exclude matching CSS files from CSS module scoping.
4142
*/
42-
constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks }) {
43+
constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks, cssModuleExceptions = [] }) {
4344
const isProduction = process.env.NODE_ENV === 'production';
4445
const mode = isProduction ? 'production' : 'development';
4546

@@ -184,6 +185,7 @@ class ScratchWebpackConfigBuilder {
184185
enableReact ? [
185186
{
186187
test: /\.css$/,
188+
exclude: cssModuleExceptions,
187189
use: [
188190
{
189191
loader: 'style-loader'
@@ -213,6 +215,25 @@ class ScratchWebpackConfigBuilder {
213215
}
214216
}
215217
]
218+
},
219+
{
220+
test: cssModuleExceptions,
221+
use: [
222+
'style-loader',
223+
'css-loader',
224+
{
225+
loader: 'postcss-loader',
226+
options: {
227+
postcssOptions: {
228+
plugins: [
229+
'postcss-import',
230+
'postcss-simple-vars',
231+
'autoprefixer'
232+
]
233+
}
234+
}
235+
}
236+
]
216237
}
217238
] : []
218239
),

0 commit comments

Comments
 (0)