diff --git a/docs/config/build-options.md b/docs/config/build-options.md index e5c566d2e2bd01..f49d5454716fff 100644 --- a/docs/config/build-options.md +++ b/docs/config/build-options.md @@ -163,7 +163,7 @@ Build as a library. `entry` is required since the library cannot use HTML as ent - **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 the value is a string, it will be used as the manifest file name. +When set to `true`, the build will also generate a `.vite/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 diff --git a/docs/guide/backend-integration.md b/docs/guide/backend-integration.md index 734c71d4cd35b8..6e391e48b23261 100644 --- a/docs/guide/backend-integration.md +++ b/docs/guide/backend-integration.md @@ -12,7 +12,7 @@ If you need a custom integration, you can follow the steps in this guide to conf // vite.config.js export default defineConfig({ build: { - // generate manifest.json in outDir + // generate .vite/manifest.json in outDir manifest: true, rollupOptions: { // overwrite default .html entry @@ -56,7 +56,7 @@ If you need a custom integration, you can follow the steps in this guide to conf ``` -3. For production: after running `vite build`, a `manifest.json` file will be generated alongside other asset files. An example manifest file looks like this: +3. For production: after running `vite build`, a `.vite/manifest.json` file will be generated alongside other asset files. An example manifest file looks like this: ```json { diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index 03fb7cf30e4c55..d208a9bcd87bb0 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -181,14 +181,14 @@ Refer to the [Vue](https://github.com/vitejs/vite-plugin-vue/tree/main/playgroun ## Generating Preload Directives -`vite build` supports the `--ssrManifest` flag which will generate `ssr-manifest.json` in build output directory: +`vite build` supports the `--ssrManifest` flag which will generate `.vite/ssr-manifest.json` in build output directory: ```diff - "build:client": "vite build --outDir dist/client", + "build:client": "vite build --outDir dist/client --ssrManifest", ``` -The above script will now generate `dist/client/ssr-manifest.json` for the client build (Yes, the SSR manifest is generated from the client build because we want to map module IDs to client files). The manifest contains mappings of module IDs to their associated chunks and asset files. +The above script will now generate `dist/client/.vite/ssr-manifest.json` for the client build (Yes, the SSR manifest is generated from the client build because we want to map module IDs to client files). The manifest contains mappings of module IDs to their associated chunks and asset files. To leverage the manifest, frameworks need to provide a way to collect the module IDs of the components that were used during a server render call. diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 99ddd29fdc9351..957ee92d046056 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -174,7 +174,7 @@ export interface BuildOptions { */ copyPublicDir?: boolean /** - * Whether to emit a manifest.json under assets dir to map hash-less filenames + * Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames * to their hashed versions. Useful when you want to generate your own HTML * instead of using the one generated by Vite. * diff --git a/packages/vite/src/node/plugins/manifest.ts b/packages/vite/src/node/plugins/manifest.ts index 0950121c0bcbe2..7f7484c1a7ae5e 100644 --- a/packages/vite/src/node/plugins/manifest.ts +++ b/packages/vite/src/node/plugins/manifest.ts @@ -157,7 +157,7 @@ export function manifestPlugin(config: ResolvedConfig): Plugin { fileName: typeof config.build.manifest === 'string' ? config.build.manifest - : 'manifest.json', + : '.vite/manifest.json', type: 'asset', source: jsonStableStringify(manifest, { space: 2 }), }) diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index 7c748205be15b4..c4d8c7b176628d 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -94,7 +94,7 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { fileName: typeof config.build.ssrManifest === 'string' ? config.build.ssrManifest - : 'ssr-manifest.json', + : '.vite/ssr-manifest.json', type: 'asset', source: jsonStableStringify(ssrManifest, { space: 2 }), }) diff --git a/playground/test-utils.ts b/playground/test-utils.ts index 39e2f56c5e6a86..fa4494a738df7e 100644 --- a/playground/test-utils.ts +++ b/playground/test-utils.ts @@ -168,7 +168,10 @@ export function findAssetFile( export function readManifest(base = ''): Manifest { return JSON.parse( - fs.readFileSync(path.join(testDir, 'dist', base, 'manifest.json'), 'utf-8'), + fs.readFileSync( + path.join(testDir, 'dist', base, '.vite/manifest.json'), + 'utf-8', + ), ) }