From dae836a81db7fda6e5100c56f99ca0b5ba901f0b Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Mon, 15 Aug 2022 18:01:34 +0200 Subject: [PATCH] feat(vite): allow disabling entry warmup (#6647) * feat(vite): allow opt-out from warming up entries * refactor: move to `warmupEntry` --- packages/schema/src/types/config.ts | 6 +++++- packages/vite/src/vite.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/schema/src/types/config.ts b/packages/schema/src/types/config.ts index 6e20162713..176ab8f540 100644 --- a/packages/schema/src/types/config.ts +++ b/packages/schema/src/types/config.ts @@ -49,5 +49,9 @@ export interface ViteConfig extends ViteUserConfig { * Bundler for dev time server-side rendering. * @default 'vite-node' */ - devBundler?: 'vite-node' | 'legacy' + devBundler?: 'vite-node' | 'legacy', + /** + * Warmup vite entrypoint caches on dev startup. + */ + warmupEntry?: boolean } diff --git a/packages/vite/src/vite.ts b/packages/vite/src/vite.ts index d4d3ca8c22..bd92dc71e0 100644 --- a/packages/vite/src/vite.ts +++ b/packages/vite/src/vite.ts @@ -101,10 +101,12 @@ export async function bundle (nuxt: Nuxt) { } }) - const start = Date.now() - warmupViteServer(server, [join('/@fs/', ctx.entry)]) - .then(() => logger.info(`Vite ${env.isClient ? 'client' : 'server'} warmed up in ${Date.now() - start}ms`)) - .catch(logger.error) + if (nuxt.options.vite.warmupEntry !== false) { + const start = Date.now() + warmupViteServer(server, [join('/@fs/', ctx.entry)]) + .then(() => logger.info(`Vite ${env.isClient ? 'client' : 'server'} warmed up in ${Date.now() - start}ms`)) + .catch(logger.error) + } }) await buildClient(ctx)