-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
58 lines (57 loc) · 1.51 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { defineConfig } from 'vite'
import vuePlugin from '@vitejs/plugin-vue'
import { join } from 'path'
import { createHtmlPlugin } from 'vite-plugin-html'
// https://vitejs.dev/config/
function resolve(dir: string) {
return join(__dirname, dir)
}
export default defineConfig({
mode: process.env.NODE_ENV,
server: {
host: 'localhost',
port: 9100,
},
resolve: {
alias: {
// 如果报错__dirname找不到,需要安装node,执行npm install @types/node --save-dev
'@': resolve('src'),
'@hooks': resolve('src/hooks'),
'@assets': resolve('src/assets'),
'@components': resolve('src/components'),
'@images': resolve('src/assets/images'),
'@views': resolve('src/views'),
'@store': resolve('src/store'),
},
extensions: ['.vue', '.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.html'],
},
build: {
outDir: resolve('/web'),
emptyOutDir: true,
target: 'esnext',
minify: 'esbuild',
},
plugins: [
vuePlugin({
script: {
refSugar: true,
},
}),
createHtmlPlugin({
minify: true,
/**
* 需要注入 index.html ejs 模版的数据
*/
inject: {
data: {
title: 'index',
injectScript:
process.env.NODE_ENV === 'production'
? `<script src="/eel.js"></script>`
: `<script src="http://localhost:9000/eel.js"></script><script>window.eel.set_host("ws://localhost:9000");</script>`,
},
},
}),
],
optimizeDeps: {},
})