From ba3c8c851e35fbdd096ffa2cc9e1be95c3171527 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Tue, 24 Jan 2023 17:07:45 +0200 Subject: [PATCH] fix(vite): proper path for main.tsx for standalone (#14575) --- packages/vite/src/utils/generator-utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/utils/generator-utils.ts b/packages/vite/src/utils/generator-utils.ts index c8e4a4bc8041d..1d4f35623e603 100644 --- a/packages/vite/src/utils/generator-utils.ts +++ b/packages/vite/src/utils/generator-utils.ts @@ -372,12 +372,15 @@ export function moveAndEditIndexHtml( let indexHtmlPath = projectConfig.targets[buildTarget].options?.index ?? `${projectConfig.root}/src/index.html`; - const mainPath = ( + let mainPath = projectConfig.targets[buildTarget].options?.main ?? `${projectConfig.root}/src/main.ts${ options.uiFramework === 'react' ? 'x' : '' - }` - ).replace(projectConfig.root, ''); + }`; + + if (projectConfig.root !== '.') { + mainPath = mainPath.replace(projectConfig.root, ''); + } if ( !tree.exists(indexHtmlPath) &&