Skip to content

Commit

Permalink
fix: an error occurred when TSconfig file changed
Browse files Browse the repository at this point in the history
  • Loading branch information
alex8088 committed Mar 31, 2022
1 parent 5569dbb commit a5c3e6b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
44 changes: 22 additions & 22 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,27 @@ import { ensureElectronEntryFile, getElectronPath } from './utils'
export async function createServer(inlineConfig: InlineConfig = {}): Promise<void> {
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) {
Expand All @@ -24,34 +43,15 @@ export async function createServer(inlineConfig: InlineConfig = {}): Promise<voi
const port = conf.port
process.env.ELECTRON_RENDERER_URL = `${protocol}//${host}:${port}`

const logger = server.config.logger
const slogger = server.config.logger

logger.info(colors.green(`dev server running for the electron renderer process at:\n`), {
clear: !logger.hasWarned
slogger.info(colors.green(`dev server running for the electron renderer process at:\n`), {
clear: !slogger.hasWarned
})

server.printUrls()
}

const logger = createLogger(inlineConfig.logLevel)

const mainViteConfig = config.config?.main
if (mainViteConfig) {
logger.info(colors.gray(`\n-----\n`))

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`))
}

ensureElectronEntryFile(inlineConfig.root)

const electronPath = getElectronPath()
Expand Down

0 comments on commit a5c3e6b

Please sign in to comment.