Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimizeDeps.entries default ignore paths #7469

Merged
merged 1 commit into from Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/config/index.md
Expand Up @@ -965,9 +965,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