Skip to content

Commit

Permalink
ViteBuilder: Allow viteFinal to modify the configuration before getOp…
Browse files Browse the repository at this point in the history
…timizeDeps triggers resolveConfig
  • Loading branch information
cr7pt0gr4ph7 committed Dec 3, 2024
1 parent 1ea70ee commit 88a9c55
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/builders/builder-vite/src/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ export async function createViteServer(options: Options, devServer: Server) {
},
},
appType: 'custom' as const,
optimizeDeps: await getOptimizeDeps(commonCfg, options),
};

const finalConfig = await presets.apply('viteFinal', config, options);

// getOptimizeDeps calls resolveConfig internally, and should therefore
// be invoked on the fully finalized configuration, in case viteFinal
// has applied some changes that were necessary for the configuration
// to be valid.
const finalConfigWithDeps = {
...finalConfig,
optimizeDeps: await getOptimizeDeps(finalConfig, options),
};

const { createServer } = await import('vite');
return createServer(await sanitizeEnvVars(options, finalConfig));
return createServer(await sanitizeEnvVars(options, finalConfigWithDeps));
}

0 comments on commit 88a9c55

Please sign in to comment.