Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ Custom options passed on pre-processor loader configuration
- **Default:** `{}`

Custom options passed on [css-loader](https://github.com/webpack-contrib/css-loader) configuration

#### `ruleOpts`
- **Type:** `{ [key:string]: any }`
- **Default:** `{}`

Custom options passed on webpack rule configuration
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const applyRule = (
cssmodules: boolean | undefined,
dev: boolean
) => {
const { preprocessor, cssOpts, loaderOpts } = opts
const { preprocessor, cssOpts, loaderOpts, ruleOpts } = opts

const loaderfn = loaders[preprocessor as PreProcessor]
const loader = loaderfn(loaderOpts)
Expand All @@ -105,6 +105,7 @@ const applyRule = (
return {
test: tests[preprocessor as PreProcessor],
use: loader(cssoptions, dev),
...ruleOpts,
}
}

Expand All @@ -113,13 +114,15 @@ export interface CSSPluginOptions {
cssmodules?: boolean
loaderOpts?: Opts
cssOpts?: Opts
ruleOpts?: Opts
}

const defaultOpts: Record<string, any> = {
preprocessor: 'postcss',
cssmodules: false,
loadersOpts: {},
cssOpts: {},
ruleOpts: {},
}

export const css = (opts: CSSPluginOptions = defaultOpts) =>
Expand Down