-
Notifications
You must be signed in to change notification settings - Fork 42
/
vite.config.ts
59 lines (58 loc) · 1.73 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
import path from 'node:path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Pages from 'vite-plugin-pages'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import VueMacros from 'unplugin-vue-macros/vite'
import Unocss from 'unocss/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { visualizer } from 'rollup-plugin-visualizer'
import VueI18n from '@intlify/unplugin-vue-i18n/vite'
export default defineConfig({
/**
* 若使用 Github Pages 进行部署,打包后的资源在 /moon-web-start 下
* 但默认会请求根目录下的资源 故此处根据 环境变量 REPOSITORY 动态设置 base
* 相当于: process.env.REPOSITORY ? '/moon-web-start/' : ''
*/
base: process.env.REPOSITORY ? `/${process.env.REPOSITORY.split('/').pop()}/` : '',
plugins: [
Vue(),
Unocss(),
Pages(),
VueMacros(),
AutoImport({
imports: ['vue', 'vue-router', 'pinia', '@vueuse/core', 'vue/macros'],
dts: 'src/auto-imports.d.ts',
dirs: ['src/composables', 'src/stores'],
vueTemplate: true,
}),
Components({
resolvers: [NaiveUiResolver()],
dirs: ['src/components/**'],
extensions: ['vue', 'tsx'],
dts: 'src/components.d.ts',
}),
visualizer({
open: false,
gzipSize: true,
brotliSize: true,
}),
VueI18n({
runtimeOnly: true,
compositionOnly: true,
fullInstall: true,
include: [path.resolve(__dirname, 'src/locales/**')],
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, './'),
},
},
server: {
port: 1888,
host: '0.0.0.0',
},
})