electron-vue-exam-single/vite.config.js
2025-08-12 18:17:07 +08:00

37 lines
917 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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',
}
}
}
})