From 70fa4b9e4127a5f17c084b7f0620dbf65ffd0499 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Fri, 25 Nov 2022 16:15:15 -0500 Subject: [PATCH] fix(react): generate lib with correct imports in vite.config.ts (#13419) --- packages/vite/src/utils/generator-utils.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/utils/generator-utils.ts b/packages/vite/src/utils/generator-utils.ts index 9a7b7d1a378b2..da222717960b7 100644 --- a/packages/vite/src/utils/generator-utils.ts +++ b/packages/vite/src/utils/generator-utils.ts @@ -415,7 +415,11 @@ ${options.includeVitest ? '/// ' : ''} import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import ViteTsConfigPathsPlugin from 'vite-tsconfig-paths'; - ${options.includeLib ? "import dts from 'vite-plugin-dts';" : ''} + ${ + options.includeLib + ? `import dts from 'vite-plugin-dts';\nimport { join } from 'path';` + : '' + } export default defineConfig({ plugins: [ @@ -436,7 +440,11 @@ ${options.includeVitest ? '/// ' : ''} ${options.includeVitest ? '/// ' : ''} import { defineConfig } from 'vite'; import ViteTsConfigPathsPlugin from 'vite-tsconfig-paths'; - ${options.includeLib ? "import dts from 'vite-plugin-dts';" : ''} + ${ + options.includeLib + ? `import dts from 'vite-plugin-dts';\nimport { join } from 'path';` + : '' + } export default defineConfig({ plugins: [