output.cssModules

  • 类型:
type CssModules = {
  auto?:
    | boolean
    | RegExp
    | ((
        resourcePath: string,
        resourceQuery: string,
        resourceFragment: string,
      ) => boolean);
  exportLocalsConvention?:
    | 'asIs'
    | 'camelCase'
    | 'camelCaseOnly'
    | 'dashes'
    | 'dashesOnly';
  exportGlobals?: boolean;
  localIdentName?: string;
  mode?:
    | 'local'
    | 'global'
    | 'pure'
    | 'icss'
    | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
  namedExport?: boolean;
};
  • 默认值:
const defaultCssModules = {
  auto: true,
  namedExport: false,
  exportGlobals: false,
  exportLocalsConvention: 'camelCase',
};

自定义 CSS 模块配置。

INFO

该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 Rsbuild - output.cssModules