diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 2bc983aadb5a..6ffeabc06572 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -64,12 +64,14 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t const config: ViteConfig = { root: viteConfig.test?.root || options.root, - esbuild: { - sourcemap: 'external', - - // Enables using ignore hint for coverage providers with @preserve keyword - legalComments: 'inline', - }, + esbuild: viteConfig.esbuild === false + ? false + : { + sourcemap: 'external', + + // Enables using ignore hint for coverage providers with @preserve keyword + legalComments: 'inline', + }, resolve: { // by default Vite resolves `module` field, which not always a native ESM module // setting this option can bypass that and fallback to cjs version