fix(css): dont remove JS chunk for pure CSS chunk when the export is used (#18307)

This commit is contained in:
翠 / green 2024-10-09 22:12:45 +09:00 committed by GitHub
parent b382f7e19c
commit 889bfc0ada
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

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

View File

@ -24,5 +24,14 @@ export default defineConfig({
},
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('foo.css')) {
return 'foo_css'
}
},
},
},
},
})