electron-vite-vue/vite.config.ts

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-07-24 07:26:24 +08:00
import { rmSync } from 'fs'
2022-08-06 10:58:11 +08:00
import path from 'path'
2022-08-24 21:00:38 +08:00
import { defineConfig } from 'vite'
2022-06-13 22:10:18 +08:00
import vue from '@vitejs/plugin-vue'
2022-08-24 21:00:38 +08:00
import electron, { onstart } from 'vite-plugin-electron'
import pkg from './package.json'
2022-06-13 22:10:18 +08:00
2022-06-15 21:47:33 +08:00
rmSync('dist', { recursive: true, force: true }) // v14.14.0
2022-06-13 22:10:18 +08:00
// https://vitejs.dev/config/
export default defineConfig({
2022-06-14 20:53:01 +08:00
plugins: [
vue(),
electron({
main: {
entry: 'electron/main/index.ts',
2022-08-24 21:00:38 +08:00
vite: {
build: {
2022-08-24 21:00:38 +08:00
// For Debug
sourcemap: true,
outDir: 'dist/electron/main',
},
2022-08-24 21:00:38 +08:00
// Will start Electron via VSCode Debug
plugins: [process.env.VSCODE_DEBUG ? onstart() : null],
},
},
preload: {
input: {
// You can configure multiple preload here
2022-08-06 10:58:11 +08:00
index: path.join(__dirname, 'electron/preload/index.ts'),
},
vite: {
build: {
2022-07-23 17:21:53 +08:00
// For Debug
sourcemap: 'inline',
outDir: 'dist/electron/preload',
2022-07-18 13:46:50 +08:00
},
},
},
// Enables use of Node.js API in the Renderer-process
2022-08-11 09:25:19 +08:00
// https://github.com/electron-vite/vite-plugin-electron/tree/main/packages/electron-renderer#electron-renderervite-serve
renderer: {},
}),
2022-06-14 20:53:01 +08:00
],
2022-08-25 08:29:44 +08:00
server: process.env.VSCODE_DEBUG ? {
host: pkg.debug.env.VITE_DEV_SERVER_HOST,
port: pkg.debug.env.VITE_DEV_SERVER_PORT,
} : undefined,
2022-06-13 22:10:18 +08:00
})