electron-vite-vue/vite.config.ts

39 lines
855 B
TypeScript
Raw Normal View History

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-04-01 10:30:24 +08:00
import { builtins } from './script/utils'
2020-08-16 20:42:52 +08:00
2021-02-17 22:27:40 +08:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
2021-02-18 16:11:08 +08:00
root: join(__dirname, 'src/render'),
2021-02-18 17:29:45 +08:00
base: './', // index.html 中静态资源加载位置
2021-02-17 22:27:40 +08:00
server: {
port: +process.env.PORT,
},
resolve: {
alias: {
2021-02-18 16:11:08 +08:00
'@': join(__dirname, 'src/render'),
2021-02-17 22:27:40 +08:00
'@root': __dirname,
},
2020-08-31 09:50:57 +08:00
},
2021-02-17 22:27:40 +08:00
build: {
outDir: join(__dirname, 'dist/render'),
2021-04-01 10:30:24 +08:00
emptyOutDir: true,
minify: false,
commonjsOptions: {},
2021-05-08 17:45:15 +08:00
assetsDir: '', // 相对路径加载问题
2021-02-17 22:27:40 +08:00
rollupOptions: {
2021-04-01 10:30:24 +08:00
external: [
...builtins(),
'electron',
2021-02-17 22:27:40 +08:00
],
2021-04-01 10:30:24 +08:00
output: {
format: 'cjs',
},
2021-02-17 22:27:40 +08:00
},
2020-09-25 11:39:39 +08:00
},
2021-02-17 22:27:40 +08:00
})