diff --git a/.changeset/chatty-spies-jog.md b/.changeset/chatty-spies-jog.md new file mode 100644 index 0000000000..e95591d911 --- /dev/null +++ b/.changeset/chatty-spies-jog.md @@ -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. diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index e07150c39d..bac87bf723 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -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: [