-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
94 lines (93 loc) · 2.76 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
import { resolve } from 'node:path'
import vue from '@vitejs/plugin-vue'
import { defineConfig, UserConfig } from 'vite'
import checker from 'vite-plugin-checker'
import viteCompression from 'vite-plugin-compression'
import viteSvgLoader from 'vite-svg-loader'
import { createMpaPlugin } from 'vite-plugin-virtual-mpa'
import vueJsx from '@vitejs/plugin-vue-jsx'
import unpluginAutoImport from 'unplugin-auto-import/vite'
import unpluginVueComponents from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import vueDevTools from 'vite-plugin-vue-devtools'
import tailwindcss from '@tailwindcss/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import mpaConfig from './configs/mpa'
export default defineConfig((): UserConfig => {
return {
root: process.cwd(),
base: './',
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
plugins: [
vue(),
vueJsx(),
vueDevTools(),
tailwindcss(),
Icons(),
viteSvgLoader({
defaultImport: 'url',
svgoConfig: {
plugins: [
{ name: 'removeAttrs', params: { attrs: ['fill'] } },
{ name: 'addClassesToSVGElement', params: { classNames: ['icon-svg'] } },
{
name: 'addAttributesToSVGElement',
params: {
attribute: { fill: 'currentColor', preserveAspectRatio: 'xMidYMid meet' }
}
}
]
}
}),
unpluginAutoImport({
dts: 'types/auto-imports.d.ts',
imports: ['vue', 'vue-router', 'pinia']
}),
unpluginVueComponents({
dts: 'types/components.d.ts',
resolvers: [AntDesignVueResolver({ importStyle: false }), IconsResolver({ prefix: 'icon' })]
}),
createMpaPlugin(mpaConfig),
viteCompression({
verbose: false,
deleteOriginFile: false,
threshold: 10240,
algorithm: 'gzip',
ext: '.gz'
}),
checker({
root: process.cwd(),
terminal: false,
vueTsc: {
tsconfigPath: 'tsconfig.app.json'
},
eslint: {
useFlatConfig: true,
lintCommand: 'eslint src'
},
stylelint: {
lintCommand: 'stylelint src/**/*.{vue,css,scss}'
}
})
],
build: {
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
assetFileNames: 'static/[ext]/asset-[name]-[hash].[ext]',
chunkFileNames: 'static/js/chunk-[name]-[hash].js',
entryFileNames: 'static/js/entry-[name]-[hash].js'
}
}
},
esbuild: {
pure: ['console.log', 'console.warn', 'console.error'],
drop: ['debugger']
}
}
})