Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit efe85b4

Browse files
felipeptchopedronauck
authored andcommitted
feat: add ruleOpts to override the default preprocessor rule options (#2)
1 parent 236018d commit efe85b4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ Custom options passed on pre-processor loader configuration
142142
- **Default:** `{}`
143143

144144
Custom options passed on [css-loader](https://github.com/webpack-contrib/css-loader) configuration
145+
146+
#### `ruleOpts`
147+
- **Type:** `{ [key:string]: any }`
148+
- **Default:** `{}`
149+
150+
Custom options passed on webpack rule configuration

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const applyRule = (
9191
cssmodules: boolean | undefined,
9292
dev: boolean
9393
) => {
94-
const { preprocessor, cssOpts, loaderOpts } = opts
94+
const { preprocessor, cssOpts, loaderOpts, ruleOpts } = opts
9595

9696
const loaderfn = loaders[preprocessor as PreProcessor]
9797
const loader = loaderfn(loaderOpts)
@@ -105,6 +105,7 @@ const applyRule = (
105105
return {
106106
test: tests[preprocessor as PreProcessor],
107107
use: loader(cssoptions, dev),
108+
...ruleOpts,
108109
}
109110
}
110111

@@ -113,13 +114,15 @@ export interface CSSPluginOptions {
113114
cssmodules?: boolean
114115
loaderOpts?: Opts
115116
cssOpts?: Opts
117+
ruleOpts?: Opts
116118
}
117119

118120
const defaultOpts: Record<string, any> = {
119121
preprocessor: 'postcss',
120122
cssmodules: false,
121123
loadersOpts: {},
122124
cssOpts: {},
125+
ruleOpts: {},
123126
}
124127

125128
export const css = (opts: CSSPluginOptions = defaultOpts) =>

0 commit comments

Comments
 (0)