Skip to content

Commit

Permalink
fix(css): ensure order of extracted CSS
Browse files Browse the repository at this point in the history
Without this the order of the extracted CSS rules is defined by the order `renderChunk` of the css plugin is called.
So with this the order of CSS rules is always in alphabetical order of the output chunks.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed May 3, 2024
1 parent 2bc5d3d commit eacd77d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
css += chunkCSSMap.get(chunk.preliminaryFileName) ?? ''
}

for (const chunkName of chunkCSSMap.keys())
// sorted chunk names to guarantee output order (deterministic output)
const chunkNames = [...chunkCSSMap.keys()].sort()
for (const chunkName of chunkNames)
collect(prelimaryNameToChunkMap.get(chunkName)?.fileName ?? '')

return css
Expand Down

0 comments on commit eacd77d

Please sign in to comment.