-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
122 lines (121 loc) · 3.31 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Unocss from 'unocss/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts';
export default defineConfig({
plugins: [
vue(),
Layouts(),
AutoImport({
imports: [ //需要全局自动导入的模块API
'vue',
'vue-i18n',
'vue-router',
'@vueuse/core',
],
dts: 'src/auto-imports.d.ts', //自动生成的导入文件路径
dirs: [ //需要自动导入的模块文件
'src/common/',
'src/stores/',
],
vueTemplate: true, //在vue模板中开启
resolvers: [
ElementPlusResolver(),
],
}),
Components({
extensions: ['vue'], //需要全局自动导入的模块组件
include: [/\.vue$/, /\.vue\?vue/], //包含匹配文件
exclude: [/[\\/]\.git[\\/]/], //过滤匹配文件
dts: 'src/components.d.ts', //自动生成的导入文件路径
dirs: [ //需要自动导入的模块文件
'src/components',
],
resolvers: [
ElementPlusResolver(),
IconsResolver({
prefix: 'icon',
enabledCollections: ['ep','carbon'],
}),
],
}),
Icons({
autoInstall: true,
}),
Unocss(),
Pages({
extensions: ['vue'], //有效的文件后缀
dirs: 'src/pages', //指定文件根目录
extendRoute(route, parent) {
return route
},
}),
VueI18n({
// runtimeOnly: true,
// compositionOnly: true,
fullInstall: true,
include: [path.resolve(__dirname, 'src/language/*')],
}),
],
// 本地服务
server:{
open:true,
port:8080,
host:"0.0.0.0",
proxy: { //设置代理
'/api': {
target: 'http://localhost:8087/', //本地
// target: 'http://xxx.xxx.xxx.xxx:8087/',
changeOrigin: true, // 是否跨域
rewrite: path => path.replace('/^\/api/', '/api'),
},
},
},
resolve: {
alias: {
'~': `${path.resolve(__dirname, 'src')}`,
'@': `${path.resolve(__dirname, 'src')}`,
}
},
css: {
//配置scss的全局变量(可选)
preprocessorOptions: {
scss: {
additionalData: '@import "./src/assets/styles/mixin.scss";',
},
},
},
esbuild: {
drop: ['console', 'debugger'],
},
build:{
target:['ES2020'],//浏览器兼容性
rollupOptions: {//Rollup打包配置
output: {
manualChunks(id) {
if (id.includes('components')){
return 'components'
}
if (id.includes('pages')){
return 'pages'
}
if (id.includes('layouts')){
return 'layouts'
}
},
},
},
outDir:'dist',//指定输出目录
assetsDir:'assets',//静态资源存放点,相对于输出目录dist
assetsInlineLimit: 4096,//默认4kb,小于此大小的资源转为base64编码
cssCodeSplit: false,//CSS是否拆分
}
})