Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ 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 }) {
constructor ({ distPath, enableReact, enableTs, libraryName, rootPath, srcPath, publicPath = '/', shouldSplitChunks, cssModuleExceptions = [] }) {
const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';

Expand Down Expand Up @@ -184,6 +185,7 @@ class ScratchWebpackConfigBuilder {
enableReact ? [
{
test: /\.css$/,
exclude: cssModuleExceptions,
use: [
{
loader: 'style-loader'
Expand Down Expand Up @@ -213,6 +215,25 @@ class ScratchWebpackConfigBuilder {
}
}
]
},
{
test: cssModuleExceptions,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
'postcss-import',
'postcss-simple-vars',
'autoprefixer'
]
}
}
}
]
}
] : []
),
Expand Down