forked from radishes-music/radishes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
98 lines (92 loc) · 2.53 KB
/
vite.config.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import path from 'node:path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vitePluginMd2Vue from 'vite-plugin-md2vue'
import usePluginImport from 'vite-plugin-importer'
import { antdDayjs } from 'antd-dayjs-vite-plugin'
import pkg from './package.json'
const resolvePath = depPath => path.resolve(__dirname, depPath)
export const __VITE_RESOLVE__ = {
alias: {
'@': resolvePath('./src'),
'@/pages': resolvePath('./src/pages'),
'@/utils': resolvePath('./src/utils'),
'@/theme': resolvePath('./src/theme'),
'@/interface': resolvePath('./src/interface'),
'@/components-global': resolvePath('./src/components-global'),
'@/components': resolvePath('./src/components'),
'@/electron': resolvePath('./src/electron'),
'@/hooks': resolvePath('./src/hooks'),
'@/layout': resolvePath('./src/layout'),
'@/store': resolvePath('./src/store'),
'@/helpers': resolvePath('./src/helpers'),
'@/modules': resolvePath('./src/modules'),
root: resolvePath('./src/../'),
'~@': resolvePath('./src'),
'~@vant': resolvePath('./node_modules/@vant')
}
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), 'VUE_APP')
const isWeb = env.VUE_APP_PLATFORM === 'browser'
return {
root: '.',
envPrefix: 'VUE_APP_',
define: {
__APP_VERSION__: `'${pkg.version}'`,
__GIT_URL__: `'${pkg.repository.url}'`
},
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
jsxInject: `import {h} from 'vue'`,
include: 'vue'
},
build: {
// outDir:'dist',
rollupOptions: {
input: {
index: resolvePath('index.html'),
lyrics: resolvePath('lyrics.html')
}
}
},
server: {
open: isWeb,
host: true,
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:32768',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
},
plugins: [
vue(),
vitePluginMd2Vue(),
vueJsx(),
usePluginImport({
libraryName: 'ant-design-vue',
libraryDirectory: 'es',
style: 'css'
}),
usePluginImport({
libraryName: 'vant',
libraryDirectory: 'es',
style: name => `${name}/style/less`
}),
antdDayjs()
],
resolve: __VITE_RESOLVE__
}
})