electron-vite-vue/vite.config.ts

42 lines
1007 B
TypeScript
Raw Normal View History

2022-06-15 21:47:33 +08:00
import { rmSync } from 'fs'
2022-06-14 20:53:01 +08:00
import { join } from 'path'
2022-06-13 22:10:18 +08:00
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
2022-06-14 20:53:01 +08:00
import electron from 'vite-plugin-electron'
import renderer from 'vite-plugin-electron/renderer'
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: {
2022-06-16 19:23:43 +08:00
entry: 'electron/main/index.ts',
2022-06-14 21:17:45 +08:00
vite: {
build: {
sourcemap: false,
2022-06-16 19:23:43 +08:00
outDir: 'dist/electron/main',
2022-06-14 21:17:45 +08:00
},
},
2022-06-14 20:53:01 +08:00
},
preload: {
input: {
// You can configure multiple preload here
2022-06-16 19:23:43 +08:00
splash: join(__dirname, 'electron/preload/splash.ts'),
2022-06-14 20:53:01 +08:00
},
2022-06-14 21:17:45 +08:00
vite: {
build: {
// For debug
sourcemap: 'inline',
2022-06-16 19:23:43 +08:00
outDir: 'dist/electron/preload',
2022-06-14 21:17:45 +08:00
}
}
2022-06-14 20:53:01 +08:00
},
}),
// Enable use Electron, Node.js API in Renderer-process
renderer(),
],
2022-06-13 22:10:18 +08:00
})