-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathvite.config.ts
91 lines (88 loc) · 2.39 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import viteCompression from 'vite-plugin-compression'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'
export default defineConfig({
plugins: [
vue(),
vueJsx(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
AutoImport({
dts: 'src/auto-imports.d.ts',
imports: ['vue', 'vue-router'],
// eslint报错解决
eslintrc: {
enabled: true, // Default `false`
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
resolvers: [ElementPlusResolver()],
}),
Components({
dirs: [
'src/components',
'src/icons',
'src/views/**/components/*.{vue|tsx}',
],
extensions: ['vue', 'tsx', 'svg'],
// 配置文件生成位置
dts: 'src/components.d.ts',
resolvers: [
ElementPlusResolver({
importStyle: 'sass',
}),
],
}),
viteCompression({
threshold: 1024000, // 对大于 1mb 的文件进行压缩
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'#': path.resolve(__dirname, 'typings'),
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
'/^~(.*)$/': 'node_modules/$1',
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/element.scss" as *;`,
},
},
},
define: {
__VUE_I18N_LEGACY_API__: false,
__VUE_I18N_FULL_INSTALL__: false,
__INTLIFY_PROD_DEVTOOLS__: false,
},
build: {
chunkSizeWarningLimit: 1024,
},
server: {
hmr: {
overlay: false,
},
port: 3002,
open: false,
https: false,
proxy: {
// '/api': {
// target: 'https://blog.csdn.net/weixin_45292658',
// changeOrigin: true,
// rewrite: path => path.replace(/^\/api/, '')
// }
},
},
})