-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathvite.config.ts
69 lines (68 loc) · 1.98 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import AutoImport from 'unplugin-auto-import/vite'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { VueAmapResolver } from '@vuemap/unplugin-resolver'
import userConfig from './config'
import { visualizer } from 'rollup-plugin-visualizer'
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3003,
host: '0.0.0.0',
hmr: true,
},
define: {
'process.env':
process.env.NODE_ENV === 'production' ? userConfig.buildEnv : userConfig.devEnv,
},
plugins: [
vue(),
vueJsx(),
VueSetupExtend(),
Components({
resolvers: [VantResolver(), VueAmapResolver()],
}),
AutoImport({
imports: ['vue', 'vue-router', 'vue-i18n'],
dts: 'src/auto-import.d.ts',
resolvers: [VueAmapResolver()],
}),
// visualizer({ open: true }),
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'@pages': resolve(__dirname, 'src/pages'),
'@components': resolve(__dirname, 'src/components'),
'@layout': resolve(__dirname, 'src/layout'),
'@api': resolve(__dirname, 'src/api'),
'@utils': resolve(__dirname, 'src/utils'),
'@store': resolve(__dirname, 'src/store'),
'@assets': resolve(__dirname, 'src/assets'),
'@i18n': resolve(__dirname, 'src/i18n'),
'@type': resolve(__dirname, 'src/type'),
},
},
build: {
sourcemap: false,
cssCodeSplit: true,
reportCompressedSize: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules') && !id.includes('vant')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString()
}
},
},
},
},
optimizeDeps: {
exclude: ['vant'],
},
})