-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
63 lines (60 loc) · 1.9 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
59
60
61
62
63
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path from 'path'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
// import { visualizer } from 'rollup-plugin-visualizer'
import { UserConfig } from 'vite'
// import eslintPlugin from 'vite-plugin-eslint'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
// const isProduction = false
const config: UserConfig = {
plugins: [
vue(),
vueJsx(),
vueSetupExtend(),
/**
* * 组件库按需引入插件
* usage: 直接使用组件,无需在任何地方导入组件
*/
Components({
resolvers: [NaiveUiResolver()],
}),
],
base: '/',
define: {
'process.env': {},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
open: false,
host: '127.0.0.1',
port: 3000,
proxy: {
'^/api/': {
target: 'https://prts.maa.plus', // 后台服务器地址
changeOrigin: true /* 允许跨域 */,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
}
// if (isProduction) {
// config.plugins.push(
// // 打包优化-可视化视图
// visualizer({
// open: true,
// gzipSize: true, //搜集gzip压缩包的大小到图表
// brotliSize: true, //搜集brotli压缩包的大小到图表
// })
// )
// }
return config
})