diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 9a60343ad69ccb..f5b4f83e1a6eb1 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -1724,6 +1724,8 @@ async function bundleConfigFile( format: isESM ? 'esm' : 'cjs', mainFields: ['main'], sourcemap: 'inline', + // the last slash is needed to make the path correct + sourceRoot: path.dirname(fileName) + path.sep, metafile: true, define: { __dirname: dirnameVarName,