mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
fix(manifest): non entry CSS chunk src was wrong (#18133)
This commit is contained in:
parent
c4e7f34d2e
commit
c148676c90
@ -61,15 +61,15 @@ If you need a custom integration, you can follow the steps in this guide to conf
|
||||
|
||||
```json [.vite/manifest.json]
|
||||
{
|
||||
"_shared-!~{003}~.js": {
|
||||
"file": "assets/shared-ChJ_j-JJ.css",
|
||||
"src": "_shared-!~{003}~.js"
|
||||
},
|
||||
"_shared-B7PI925R.js": {
|
||||
"file": "assets/shared-B7PI925R.js",
|
||||
"name": "shared",
|
||||
"css": ["assets/shared-ChJ_j-JJ.css"]
|
||||
},
|
||||
"_shared-ChJ_j-JJ.css": {
|
||||
"file": "assets/shared-ChJ_j-JJ.css",
|
||||
"src": "_shared-ChJ_j-JJ.css"
|
||||
},
|
||||
"baz.js": {
|
||||
"file": "assets/baz-B2H3sXNv.js",
|
||||
"name": "baz",
|
||||
|
@ -57,7 +57,10 @@ export function manifestPlugin(): Plugin {
|
||||
const buildOptions = this.environment.config.build
|
||||
|
||||
function getChunkName(chunk: OutputChunk) {
|
||||
return getChunkOriginalFileName(chunk, root, format)
|
||||
return (
|
||||
getChunkOriginalFileName(chunk, root, format) ??
|
||||
`_` + path.basename(chunk.fileName)
|
||||
)
|
||||
}
|
||||
|
||||
function getInternalImports(imports: string[]): string[] {
|
||||
@ -150,7 +153,7 @@ export function manifestPlugin(): Plugin {
|
||||
const src =
|
||||
chunk.originalFileNames.length > 0
|
||||
? chunk.originalFileNames[0]
|
||||
: chunk.names[0]
|
||||
: '_' + path.basename(chunk.fileName)
|
||||
const isEntry = entryCssAssetFileNames.has(chunk.fileName)
|
||||
const asset = createAsset(chunk, src, isEntry)
|
||||
|
||||
@ -189,7 +192,7 @@ export function getChunkOriginalFileName(
|
||||
chunk: OutputChunk | RenderedChunk,
|
||||
root: string,
|
||||
format: InternalModuleFormat,
|
||||
): string {
|
||||
): string | undefined {
|
||||
if (chunk.facadeModuleId) {
|
||||
let name = normalizePath(path.relative(root, chunk.facadeModuleId))
|
||||
if (format === 'system' && !chunk.name.includes('-legacy')) {
|
||||
@ -198,7 +201,5 @@ export function getChunkOriginalFileName(
|
||||
name = name.slice(0, endPos) + `-legacy` + ext
|
||||
}
|
||||
return name.replace(/\0/g, '')
|
||||
} else {
|
||||
return `_` + path.basename(chunk.fileName)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user