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'
|
2022-06-30 22:16:12 +08:00
|
|
|
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(),
|
2022-06-27 10:26:32 +08:00
|
|
|
electron({
|
|
|
|
main: {
|
|
|
|
entry: 'electron/main/index.ts',
|
2022-08-24 21:00:38 +08:00
|
|
|
vite: {
|
2022-06-27 10:26:32 +08:00
|
|
|
build: {
|
2022-08-24 21:00:38 +08:00
|
|
|
// For Debug
|
|
|
|
sourcemap: true,
|
2022-06-27 10:26:32 +08:00
|
|
|
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],
|
|
|
|
},
|
2022-06-27 10:26:32 +08:00
|
|
|
},
|
|
|
|
preload: {
|
|
|
|
input: {
|
|
|
|
// You can configure multiple preload here
|
2022-08-06 10:58:11 +08:00
|
|
|
index: path.join(__dirname, 'electron/preload/index.ts'),
|
2022-06-27 10:26:32 +08:00
|
|
|
},
|
|
|
|
vite: {
|
|
|
|
build: {
|
2022-07-23 17:21:53 +08:00
|
|
|
// For Debug
|
2022-06-27 10:26:32 +08:00
|
|
|
sourcemap: 'inline',
|
|
|
|
outDir: 'dist/electron/preload',
|
2022-07-18 13:46:50 +08:00
|
|
|
},
|
|
|
|
},
|
2022-06-27 10:26:32 +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
|
2022-06-27 10:26:32 +08:00
|
|
|
renderer: {},
|
|
|
|
}),
|
2022-06-14 20:53:01 +08:00
|
|
|
],
|
2022-08-25 08:29:44 +08:00
|
|
|
server: process.env.VSCODE_DEBUG ? {
|
2022-09-01 08:44:56 +08:00
|
|
|
host: pkg.debug.env.VITE_DEV_SERVER_HOSTNAME,
|
2022-08-25 08:29:44 +08:00
|
|
|
port: pkg.debug.env.VITE_DEV_SERVER_PORT,
|
|
|
|
} : undefined,
|
2022-06-13 22:10:18 +08:00
|
|
|
})
|