File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @vanilla-extract/vite-plugin ' : patch
3+ ---
4+
5+ Fixes a bug with vite where "?used" is appended to the file path of css files.
6+
7+ This could cause different class name hashes to be generated between SSR and client builds.
8+ This was introduced in vite 2.6.0.
Original file line number Diff line number Diff line change @@ -71,16 +71,19 @@ export function vanillaExtractPlugin({
7171 return null ;
7272 }
7373
74+ const usedIndex = id . indexOf ( '?used' ) ;
75+ const fixedId = usedIndex > 0 ? id . substring ( 0 , usedIndex ) : id ;
76+
7477 if ( ssr || useRuntime ) {
7578 return addFileScope ( {
7679 source : code ,
77- filePath : normalizePath ( path . relative ( packageInfo . dirname , id ) ) ,
80+ filePath : normalizePath ( path . relative ( packageInfo . dirname , fixedId ) ) ,
7881 packageInfo,
7982 } ) . source ;
8083 }
8184
8285 const { source, watchFiles } = await compile ( {
83- filePath : id ,
86+ filePath : fixedId ,
8487 cwd : config . root ,
8588 } ) ;
8689
@@ -90,7 +93,7 @@ export function vanillaExtractPlugin({
9093
9194 return processVanillaFile ( {
9295 source,
93- filePath : id ,
96+ filePath : fixedId ,
9497 outputCss : ! ssr ,
9598 identOption :
9699 identifiers ?? ( config . mode === 'production' ? 'short' : 'debug' ) ,
You can’t perform that action at this time.
0 commit comments