Skip to content

Commit

Permalink
docs(chunkSplitting): add manualChunks object form syntax warning w…
Browse files Browse the repository at this point in the history
…hen it is used with the `splitVendorChunk` plugin (#13431)

Co-authored-by: patak <matias.capeletto@gmail.com>
  • Loading branch information
Ilanaya and patak-dev committed Jun 6, 2023
1 parent 2bd6077 commit 17511e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/guide/build.md
Expand Up @@ -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`:
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/plugins/splitVendorChunk.ts
Expand Up @@ -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
}
Expand Down

0 comments on commit 17511e0

Please sign in to comment.