-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
145 lines (135 loc) · 4.1 KB
/
Copy pathvite.config.ts
File metadata and controls
145 lines (135 loc) · 4.1 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import vue from "@vitejs/plugin-vue"
import restart from 'vite-plugin-restart'
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite"
import tailwindcss from "tailwindcss"
import autoprefixer from "autoprefixer"
import Layouts from "vite-plugin-vue-meta-layouts"
import Pages from "vite-plugin-pages"
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-vue-components/vite"
import { ElementPlusResolver } from "unplugin-vue-components/resolvers"
import Icons from "unplugin-icons/vite"
import IconsResolver from "unplugin-icons/resolver"
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import { viteMockServe } from "vite-plugin-mock"
import path from "path"
const pathSrc = path.resolve(__dirname, "src");
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const env = loadEnv(mode, process.cwd());
return {
base: "./",
resolve: {
alias: { "@": pathSrc }
},
css: {
modules: {
generateScopedName: env.VITE_USER_NODE_ENV === 'production' ? '[hash:base64:6]' : '[name]__[local]'
},
preprocessorOptions: {
scss: {
additionalData: `@use "@/assets/styles/variables.scss" as *;`
}
},
postcss: {
plugins: [tailwindcss(), autoprefixer()]
}
},
server: {
host: "0.0.0.0",
port: Number(env.VITE_APP_PORT),
open: false,
allowedHosts: true, // For Intranet penetration
watch: { usePolling: false }, // For non-docker environments, please set true
proxy: {
[env.VITE_APP_BASE_API]: {
changeOrigin: true,
target: env.VITE_APP_TARGET_URL,
rewrite: path => path.replace(
new RegExp("^" + env.VITE_APP_BASE_API),
env.VITE_APP_TARGET_BASE_API
)
}
}
},
plugins: [
Pages({
dirs: 'src/pages',
extensions: ['vue'],
routeStyle: 'nuxt',
importMode: "sync",
exclude: ['**/components/*.vue']
}),
Layouts({
target: 'src/Layouts',
defaultLayout: 'default'
}),
vue(),
VueSetupExtend(),
AutoImport({
imports: ["vue", "@vueuse/core"],
dirs: ["src/composable"],
resolvers: [ElementPlusResolver(), IconsResolver({ prefix: 'i' })],
eslintrc: {
enabled: false,
filepath: "./.eslintrc-auto-import.json",
globalsPropValue: true
},
vueTemplate: true,
dts: 'src/types/auto-imports.d.ts'
}),
Components({
resolvers: [
// Automatically import Element Plus components
ElementPlusResolver(),
// Automatically register icon components
IconsResolver({
enabledCollections: ["ep"],
prefix: "i"
})
],
dirs: ["src/components"],
dts: false
}),
Icons({ autoInstall: true }),
createSvgIconsPlugin({
iconDirs: [path.resolve(pathSrc, "assets/icons")],
symbolId: "icon-[dir]-[name]"
}),
restart({
restart: ['src/Layouts/**/*']
}),
viteMockServe({
ignore: /^_/,
mockPath: "mock",
enable: true, // Please set the real scene mode === "development"
logger: true
})
],
optimizeDeps: {
include: [
"vue",
"vue-router",
"pinia",
"axios",
"@vueuse/core",
"sortablejs",
"path-to-regexp",
"echarts"
]
},
build: {
chunkSizeWarningLimit: 2000, // Eliminate warning when package size exceeds 500kb
minify: "terser",
terserOptions: {
compress: {
keep_infinity: true, // Prevent Infinity from being compressed to 1/0, which may cause performance issues on Chrome
drop_console: true, // Remove console method from production environment
drop_debugger: true // Remove debugger method from production environment
},
format: { comments: false } // delete comment
},
reportCompressedSize: true
}
}
})