From a5c3e6b2307ee062f09c77771fcfff01ccbc7828 Mon Sep 17 00:00:00 2001 From: alex8088 <244096523@qq.com> Date: Thu, 31 Mar 2022 19:56:42 +0800 Subject: [PATCH] fix: an error occurred when TSconfig file changed --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/server.ts | 44 ++++++++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 834e985..778e026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v1.0.2 (_2022-03-31_) + +#### Bug fixes + +- fix: an error occurred when `tsconfig` file changed + ### v1.0.1 (_2022-03-28_) #### Prefs diff --git a/package.json b/package.json index 7a9b6e9..b5759a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron-vite", - "version": "1.0.1", + "version": "1.0.2", "description": "Use vite for your electron app.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/server.ts b/src/server.ts index 04859c6..bb2267a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -7,8 +7,27 @@ import { ensureElectronEntryFile, getElectronPath } from './utils' export async function createServer(inlineConfig: InlineConfig = {}): Promise { const config = await resolveConfig(inlineConfig, 'serve', 'development') if (config.config) { + const logger = createLogger(inlineConfig.logLevel) + + const mainViteConfig = config.config?.main + if (mainViteConfig) { + await viteBuild(mainViteConfig) + + logger.info(colors.green(`\nbuild the electron main process successfully`)) + } + + const preloadViteConfig = config.config?.preload + if (preloadViteConfig) { + logger.info(colors.gray(`\n-----\n`)) + await viteBuild(preloadViteConfig) + + logger.info(colors.green(`\nbuild the electron preload files successfully`)) + } + const rendererViteConfig = config.config?.renderer if (rendererViteConfig) { + logger.info(colors.gray(`\n-----\n`)) + const server = await ViteCreateServer(rendererViteConfig) if (!server.httpServer) { @@ -24,34 +43,15 @@ export async function createServer(inlineConfig: InlineConfig = {}): Promise