0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Only add framework component formats to Vite’s optimizeDeps (#11472)

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
This commit is contained in:
Chris Swithinbank 2024-07-17 09:35:02 +02:00 committed by Emanuele Stoppa
parent a3f819f29b
commit f6a7824597
2 changed files with 7 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Avoids targeting all files in the `src/` directory for eager optimization by Vite. After this change, only JSX, Vue, Svelte, and Astro components get scanned for early optimization.

View file

@ -120,13 +120,8 @@ export async function createVite(
customLogger: createViteLogger(logger, settings.config.vite.logLevel),
appType: 'custom',
optimizeDeps: {
// Scan all files within `srcDir` except for known server-code (e.g endpoints)
entries: [
`${srcDirPattern}!(pages)/**/*`, // All files except for pages
`${srcDirPattern}pages/**/!(*.js|*.mjs|*.ts|*.mts)`, // All pages except for endpoints
`${srcDirPattern}pages/**/_*.{js,mjs,ts,mts}`, // Remaining JS/TS files prefixed with `_` (not endpoints)
`${srcDirPattern}pages/**/_*/**/*.{js,mjs,ts,mts}`, // Remaining JS/TS files within directories prefixed with `_` (not endpoints)
],
// Scan for component code within `srcDir`
entries: [`${srcDirPattern}**/*.{jsx,tsx,vue,svelte,html,astro}`],
exclude: ['astro', 'node-fetch'],
},
plugins: [