diff --git a/docs/guide/build.md b/docs/guide/build.md index 7b711fe03a0bea..f817afaa6614bc 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -60,6 +60,10 @@ export default defineConfig({ This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkCache })` factory, in case composition with custom logic is needed. `cache.reset()` needs to be called at `buildStart` for build watch mode to work correctly in this case. +::: warning +You should use `build.rollupOptions.output.manualChunks` function form when using this plugin. If the object form is used, the plugin won't have any effect. +::: + ## Rebuild on files changes You can enable rollup watcher with `vite build --watch`. Or, you can directly adjust the underlying [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch) via `build.watch`: diff --git a/packages/vite/src/node/plugins/splitVendorChunk.ts b/packages/vite/src/node/plugins/splitVendorChunk.ts index efe0a18a2c9440..b8c5d2ca855b61 100644 --- a/packages/vite/src/node/plugins/splitVendorChunk.ts +++ b/packages/vite/src/node/plugins/splitVendorChunk.ts @@ -116,6 +116,10 @@ export function splitVendorChunkPlugin(): Plugin { } // else, leave the object form of manualChunks untouched, as // we can't safely replicate rollup handling. + // eslint-disable-next-line no-console + console.warn( + "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.manualChunks`. Consider using the function form instead.", + ) } else { output.manualChunks = viteManualChunks }