2021-02-18 16:11:08 +08:00
|
|
|
require('dotenv').config({ path: join(__dirname, '.env') })
|
|
|
|
|
2021-02-17 22:27:40 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
2021-02-18 16:11:08 +08:00
|
|
|
import { join } from 'path'
|
2021-05-16 19:53:54 +08:00
|
|
|
import { builtins } from './script/utils'
|
2021-05-23 10:35:34 +08:00
|
|
|
import electron from 'vitejs-plugin-electron'
|
2021-05-15 16:30:59 +08:00
|
|
|
|
|
|
|
const root = join(__dirname, 'src/render')
|
2020-08-16 20:42:52 +08:00
|
|
|
|
2021-05-16 20:14:05 +08:00
|
|
|
export default defineConfig(env => {
|
|
|
|
const isserve = env.command === 'serve'
|
|
|
|
|
|
|
|
return {
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
2021-05-23 10:35:34 +08:00
|
|
|
isserve && electron({}),
|
|
|
|
].filter(Boolean),
|
2021-05-16 20:14:05 +08:00
|
|
|
root,
|
|
|
|
base: './', // index.html 中静态资源加载位置
|
|
|
|
server: {
|
|
|
|
port: +process.env.PORT,
|
2021-02-17 22:27:40 +08:00
|
|
|
},
|
2021-05-16 20:14:05 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@render': join(__dirname, 'src/render'),
|
|
|
|
'@main': join(__dirname, 'src/main'),
|
|
|
|
'@src': join(__dirname, 'src'),
|
|
|
|
'@root': __dirname,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
optimizeDeps: {
|
|
|
|
exclude: [
|
2021-04-01 10:30:24 +08:00
|
|
|
'electron',
|
2021-02-17 22:27:40 +08:00
|
|
|
],
|
2021-05-16 20:14:05 +08:00
|
|
|
},
|
|
|
|
build: {
|
|
|
|
outDir: join(__dirname, 'dist/render'),
|
|
|
|
emptyOutDir: true,
|
|
|
|
minify: false,
|
|
|
|
commonjsOptions: {},
|
|
|
|
assetsDir: '', // 相对路径 加载问题
|
|
|
|
sourcemap: true,
|
|
|
|
rollupOptions: {
|
|
|
|
external: [
|
|
|
|
...builtins(),
|
|
|
|
'electron',
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
format: 'cjs',
|
|
|
|
},
|
2021-04-01 10:30:24 +08:00
|
|
|
},
|
2021-02-17 22:27:40 +08:00
|
|
|
},
|
2021-05-16 20:14:05 +08:00
|
|
|
}
|
2021-02-17 22:27:40 +08:00
|
|
|
})
|