37 lines
917 B
JavaScript
37 lines
917 B
JavaScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||
import electron from 'vite-plugin-electron'
|
||
import { fileURLToPath } from 'url';
|
||
|
||
export default defineConfig({
|
||
// 添加base配置,确保静态资源使用相对路径
|
||
base: './',
|
||
plugins: [
|
||
vue(),
|
||
vueDevTools(),
|
||
electron({
|
||
entry: 'electron/main.js',
|
||
onstart(options) {
|
||
// 确保只启动一个 Electron 实例
|
||
options.startup(['.', '--no-sandbox']);
|
||
}
|
||
}),
|
||
],
|
||
resolve: {
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||
},
|
||
},
|
||
build: {
|
||
// 确保打包后的文件使用相对路径
|
||
rollupOptions: {
|
||
output: {
|
||
assetFileNames: 'assets/[name]-[hash].[ext]',
|
||
chunkFileNames: 'chunks/[name]-[hash].js',
|
||
entryFileNames: 'entry-[name]-[hash].js',
|
||
}
|
||
}
|
||
}
|
||
})
|