Skip to content

Commit

Permalink
feat: 开启 css modules 导出类名的驼峰转换
Browse files Browse the repository at this point in the history
  • Loading branch information
longgui.wjb committed Jan 17, 2022
1 parent 7183c45 commit 1e6a13f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/middleware-rollup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,16 @@ _说明:会检查当前依赖的 `react` 版本是否支持 `jsxRuntime`,如
### `cssModules`

类型:`boolean | Object`<br>
默认值:`false`
默认值:`{ localsConvention: 'camelCase' }`

是否开启 CSS modules 或设置 `postcss-modules` 选项,详细说明请查看[相关文档](https://github.com/egoist/rollup-plugin-postcss#modules)

### `autoCssModules`

类型:`boolean`<br>
默认值:`true`

是否开启 `CSS Module` ,详细说明请查看[相关文档](https://github.com/egoist/rollup-plugin-postcss#modules)
是否自动对 `.module.*` 文件开启 CSS modules ,详细说明请查看[相关文档](https://github.com/egoist/rollup-plugin-postcss#automodules)

### `less`

Expand Down
12 changes: 10 additions & 2 deletions packages/middleware-rollup/src/getRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const getRollupConfig = async (
iife,
extractCSS = true,
injectCSS = true,
cssModules: modules = false,
cssModules: modules,
autoCssModules: autoModules = true,
less: lessOpts = {},
sass: sassOpts = {},
postcss: postcssOpts = {},
Expand Down Expand Up @@ -219,7 +220,14 @@ export const getRollupConfig = async (
postcss({
extract: extractCSS,
inject: injectCSS,
modules,
modules:
typeof modules === "object"
? {
localsConvention: "camelCase",
...modules,
}
: modules,
autoModules,
minimize: !!minCSS,
use: {
sass: { quietDeps: true, ...sassOpts },
Expand Down
1 change: 1 addition & 0 deletions packages/middleware-rollup/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface IBundleOptions {
extractCSS?: boolean | string;
injectCSS?: boolean | Record<string, any>;
cssModules?: boolean | Record<string, any>;
autoCssModules?: boolean;
less?: Record<string, any>;
sass?: Record<string, any>;
postcss?: PostCSSPluginConf;
Expand Down

0 comments on commit 1e6a13f

Please sign in to comment.