Skip to content

Commit

Permalink
fix: optimizeDeps.entries default ignore paths (#7469)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 27, 2022
1 parent f10c7cc commit 4c95e99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/config/index.md
Expand Up @@ -973,9 +973,9 @@ export default defineConfig({

- **Type:** `string | string[]`

By default, Vite will crawl your `index.html` to detect dependencies that need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead.
By default, Vite will crawl all your `.html` files to detect dependencies that need to be pre-bundled (ignoring `node_modules`, `build.outDir`, `__tests__` and `coverage`). If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead.

If neither of these fit your needs, you can specify custom entries using this option - the value should be a [fast-glob pattern](https://github.com/mrmlnc/fast-glob#basic-syntax) or array of patterns that are relative from Vite project root. This will overwrite default entries inference.
If neither of these fit your needs, you can specify custom entries using this option - the value should be a [fast-glob pattern](https://github.com/mrmlnc/fast-glob#basic-syntax) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitily defined. If other folders needs to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`.

### optimizeDeps.exclude

Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/node/optimizer/scan.ts
Expand Up @@ -142,7 +142,10 @@ function globEntries(pattern: string | string[], config: ResolvedConfig) {
ignore: [
'**/node_modules/**',
`**/${config.build.outDir}/**`,
`**/__tests__/**`
// if there aren't explicit entries, also ignore other common folders
...(config.optimizeDeps.entries
? []
: [`**/__tests__/**`, `**/coverage/**`])
],
absolute: true
})
Expand Down

0 comments on commit 4c95e99

Please sign in to comment.