Skip to content

Commit 889bfc0

Browse files
authoredOct 9, 2024··
fix(css): dont remove JS chunk for pure CSS chunk when the export is used (#18307)
1 parent b382f7e commit 889bfc0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎packages/vite/src/node/plugins/css.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
568568
let chunkCSS = ''
569569
// the chunk is empty if it's a dynamic entry chunk that only contains a CSS import
570570
const isJsChunkEmpty = code === '' && !chunk.isEntry
571-
let isPureCssChunk = true
571+
let isPureCssChunk = chunk.exports.length === 0
572572
const ids = Object.keys(chunk.modules)
573573
for (const id of ids) {
574574
if (styles.has(id)) {

‎playground/glob-import/vite.config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,14 @@ export default defineConfig({
2424
},
2525
build: {
2626
sourcemap: true,
27+
rollupOptions: {
28+
output: {
29+
manualChunks(id) {
30+
if (id.includes('foo.css')) {
31+
return 'foo_css'
32+
}
33+
},
34+
},
35+
},
2736
},
2837
})

0 commit comments

Comments
 (0)
Please sign in to comment.