File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,9 +2,7 @@ import fs from 'fs-extra';
22import path from 'path' ;
33import postcss from 'postcss' ;
44import postcssModules from 'postcss-modules' ;
5- import { getTempDir , findFiles } from './utils' ;
6-
7- const generateScopedName = '[hash:base64:8]_[local]' ;
5+ import { getTempDir , findFiles , generateScopedName } from './utils' ;
86
97export async function preprocessCssModules ( rootDir : string ) : Promise < void > {
108 const srcDir = path . join ( rootDir , 'src' ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ import fs from 'fs-extra';
22import { glob } from 'glob' ;
33import path from 'path' ;
44
5+ /**
6+ * Shared CSS modules scoped name pattern.
7+ * Used by both Vite config and CSS preprocessing to ensure consistency.
8+ */
9+ export const generateScopedName = '[local]__[hash:base64:5]' ;
10+
511export const fileExists = async ( filePath : string ) : Promise < boolean > => {
612 try {
713 await fs . access ( filePath ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { externalizeDeps } from 'vite-plugin-externalize-deps';
77import tsconfigPaths from 'vite-tsconfig-paths' ;
88import { visualizer } from 'rollup-plugin-visualizer' ;
99import { cssColocatePlugin } from './plugins/css-colocate' ;
10+ import { generateScopedName } from './plugins/css-colocate/utils' ;
1011
1112const srcDir = path . resolve ( __dirname , 'src' ) . replace ( / \\ / g, '/' ) ;
1213
@@ -81,10 +82,7 @@ const viteConfig = defineConfig({
8182 css : {
8283 modules : {
8384 // Generate predictable class names for debugging in dev
84- generateScopedName :
85- process . env . NODE_ENV === 'production'
86- ? '[hash:base64:8]'
87- : '[name]__[local]__[hash:base64:5]' ,
85+ generateScopedName,
8886 } ,
8987 } ,
9088 plugins : [
You can’t perform that action at this time.
0 commit comments