Skip to content

Commit 121295f

Browse files
committed
feat: allow for css module exceptions
1 parent 268bd55 commit 121295f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/index.cjs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ScratchWebpackConfigBuilder {
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.
4141
*/
42-
constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks }) {
42+
constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks, cssModuleExceptions = [] }) {
4343
const isProduction = process.env.NODE_ENV === 'production';
4444
const mode = isProduction ? 'production' : 'development';
4545

@@ -184,6 +184,7 @@ class ScratchWebpackConfigBuilder {
184184
enableReact ? [
185185
{
186186
test: /\.css$/,
187+
exclude: cssModuleExceptions,
187188
use: [
188189
{
189190
loader: 'style-loader'
@@ -213,6 +214,25 @@ class ScratchWebpackConfigBuilder {
213214
}
214215
}
215216
]
217+
},
218+
{
219+
test: cssModuleExceptions,
220+
use: [
221+
'style-loader',
222+
'css-loader',
223+
{
224+
loader: 'postcss-loader',
225+
options: {
226+
postcssOptions: {
227+
plugins: [
228+
'postcss-import',
229+
'postcss-simple-vars',
230+
'autoprefixer'
231+
]
232+
}
233+
}
234+
}
235+
]
216236
}
217237
] : []
218238
),

0 commit comments

Comments
 (0)