mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
feat: custom manifest file name (#6667)
This commit is contained in:
parent
2eabcb9a30
commit
e385346c53
@ -772,19 +772,19 @@ export default defineConfig({
|
||||
|
||||
### build.manifest
|
||||
|
||||
- **Type:** `boolean`
|
||||
- **Type:** `boolean | string`
|
||||
- **Default:** `false`
|
||||
- **Related:** [Backend Integration](/guide/backend-integration)
|
||||
|
||||
When set to `true`, the build will also generate a `manifest.json` file that contains a mapping of non-hashed asset filenames to their hashed versions, which can then be used by a server framework to render the correct asset links.
|
||||
When set to `true`, the build will also generate a `manifest.json` file that contains a mapping of non-hashed asset filenames to their hashed versions, which can then be used by a server framework to render the correct asset links. When the value is a string, it will be used as the manifest file name.
|
||||
|
||||
### build.ssrManifest
|
||||
|
||||
- **Type:** `boolean`
|
||||
- **Type:** `boolean | string`
|
||||
- **Default:** `false`
|
||||
- **Related:** [Server-Side Rendering](/guide/ssr)
|
||||
|
||||
When set to `true`, the build will also generate a SSR manifest for determining style links and asset preload directives in production.
|
||||
When set to `true`, the build will also generate a SSR manifest for determining style links and asset preload directives in production. When the value is a string, it will be used as the manifest file name.
|
||||
|
||||
### build.ssr
|
||||
|
||||
|
@ -179,7 +179,7 @@ export interface BuildOptions {
|
||||
* ```
|
||||
* @default false
|
||||
*/
|
||||
manifest?: boolean
|
||||
manifest?: boolean | string
|
||||
/**
|
||||
* Build in library mode. The value should be the global name of the lib in
|
||||
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
||||
@ -195,7 +195,7 @@ export interface BuildOptions {
|
||||
* Generate SSR manifest for determining style links and asset preload
|
||||
* directives in production.
|
||||
*/
|
||||
ssrManifest?: boolean
|
||||
ssrManifest?: boolean | string
|
||||
/**
|
||||
* Set to false to disable reporting compressed chunk sizes.
|
||||
* Can slightly improve build speed.
|
||||
|
@ -149,8 +149,8 @@ cli
|
||||
`[boolean | "terser" | "esbuild"] enable/disable minification, ` +
|
||||
`or specify minifier to use (default: esbuild)`
|
||||
)
|
||||
.option('--manifest', `[boolean] emit build manifest json`)
|
||||
.option('--ssrManifest', `[boolean] emit ssr manifest json`)
|
||||
.option('--manifest [name]', `[boolean | string] emit build manifest json`)
|
||||
.option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`)
|
||||
.option(
|
||||
'--emptyOutDir',
|
||||
`[boolean] force empty outDir when it's outside of root`
|
||||
|
@ -113,7 +113,10 @@ export function manifestPlugin(config: ResolvedConfig): Plugin {
|
||||
const outputLength = Array.isArray(output) ? output.length : 1
|
||||
if (outputCount >= outputLength) {
|
||||
this.emitFile({
|
||||
fileName: `manifest.json`,
|
||||
fileName:
|
||||
typeof config.build.manifest === 'string'
|
||||
? config.build.manifest
|
||||
: 'manifest.json',
|
||||
type: 'asset',
|
||||
source: JSON.stringify(manifest, null, 2)
|
||||
})
|
||||
|
@ -96,7 +96,10 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin {
|
||||
}
|
||||
|
||||
this.emitFile({
|
||||
fileName: 'ssr-manifest.json',
|
||||
fileName:
|
||||
typeof config.build.ssrManifest === 'string'
|
||||
? config.build.ssrManifest
|
||||
: 'ssr-manifest.json',
|
||||
type: 'asset',
|
||||
source: JSON.stringify(ssrManifest, null, 2)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user