-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
44 lines (42 loc) · 1.46 KB
/
vite.config.js
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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
})
],
base: './',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
rollupOptions: {
output: {
entryFileNames: 'js/[name]-[hash].js', // 指定 JS 文件的输出路径及命名规则
chunkFileNames: 'js/[name]-[hash].js', // 指定分片文件的输出路径及命名规则
assetFileNames: (assetInfo) => {
// 设置不同类型文件的输出路径及命名规则
if (assetInfo.type === 'asset' && /\.(jpe?g|png|gif|svg)$/i.test(assetInfo.name)) {
return 'img/[name].[hash].[ext]' // 图像文件输出路径及命名规则
}
if (assetInfo.type === 'asset' && /\.(ttf|woff|woff2|eot)$/i.test(assetInfo.name)) {
return 'fonts/[name].[hash].[ext]' // 字体文件输出路径及命名规则
}
return '[ext]/name1-[hash].[ext]' // 其他资源文件输出路径及命名规则
}
}
}
}
})