generated from VuePlusOrg/vue3-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
68 lines (63 loc) · 1.62 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
import { fileURLToPath, URL } from 'node:url'
import { dirname, resolve } from 'node:path'
import { defineConfig, type PluginOption } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { visualizer } from 'rollup-plugin-visualizer'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import Pages from 'vite-plugin-pages'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { viteMockServe } from 'vite-plugin-mock'
const IS_PRODUCTION = process.env.NODE_ENV === 'production'
const plugins: PluginOption[] = [
vue(),
vueJsx(),
Components({
dirs: ['src/components'],
resolvers: [AntDesignVueResolver()],
extensions: ['vue'],
dts: 'src/components.d.ts'
}),
Pages({
dirs: [
{ dir: 'src/views', baseRoute: '' },
{ dir: 'src/views/home', baseRoute: '/' }
],
importMode: 'async',
exclude: ['**/components/**']
}),
VueSetupExtend(),
VueI18nPlugin({
include: resolve(dirname(fileURLToPath(import.meta.url)), 'src/i18n/*')
}),
viteMockServe({
mockPath: 'mock',
supportTs: true
})
]
if (IS_PRODUCTION) {
plugins.push(
visualizer({
open: true,
gzipSize: true,
brotliSize: true
}) as PluginOption
)
}
export default defineConfig({
plugins,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
logLevel: IS_PRODUCTION ? 'silent' : 'info',
server: {
host: '0.0.0.0'
},
build: {
target: 'es6'
}
})