Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dev): added assets to manifest #6649

Merged
merged 13 commits into from
Jun 19, 2022
10 changes: 9 additions & 1 deletion packages/vite/src/node/plugins/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path'
import type { OutputChunk } from 'rollup'
import type { OutputChunk, OutputAsset } from 'rollup'
import type { ResolvedConfig } from '..'
import type { Plugin } from '../plugin'
import { chunkToEmittedCssFileMap } from './css'
Expand Down Expand Up @@ -101,10 +101,18 @@ export function manifestPlugin(config: ResolvedConfig): Plugin {
return manifestChunk
}

function createAsset(chunk: OutputAsset): ManifestChunk {
return {
file: chunk.fileName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having src here if it exists would be helpful too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be the src same as the name of the asset? Also not sure how to do this, asset returns only name

if (chunk.name) {
  manifestAsset.src = chunk.name
}

Would this be correct? I don't know how to get full path for assets, they don't include facadeModuleId

}
}

for (const file in bundle) {
const chunk = bundle[file]
if (chunk.type === 'chunk') {
manifest[getChunkName(chunk)] = createChunk(chunk)
} else if (chunk.type === 'asset' && typeof chunk.name === 'string') {
manifest[chunk.name] = createAsset(chunk)
}
}

Expand Down