-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
42 lines (41 loc) · 1.23 KB
/
vite.config.js
File metadata and controls
42 lines (41 loc) · 1.23 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
import { defineConfig } from 'vite'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
root: 'src',
base: '/',
publicDir: '../public',
build: {
outDir: '../dist',
emptyOutDir: true,
sourcemap: false,
assetsInlineLimit: 0,
rollupOptions: {
input: {
main: resolve(__dirname, 'src/index.html')
},
output: {
// 确保生成的文件保持原有的目录结构
assetFileNames: (assetInfo) => {
const info = assetInfo.name.split('.')
const ext = info[info.length - 1]
if (/\.(woff2?|eot|ttf|otf)$/i.test(assetInfo.name)) {
return `assets/webfonts/[name][extname]`
}
if (/\.(png|jpe?g|gif|svg|ico)$/i.test(assetInfo.name)) {
return `assets/images/[name][extname]`
}
if (/\.(css)$/i.test(assetInfo.name)) {
return `assets/css/[name][extname]`
}
if (/\.(js)$/i.test(assetInfo.name)) {
return `assets/js/[name][extname]`
}
return `assets/[ext]/[name][extname]`
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js'
}
}
}
})