-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
49 lines (43 loc) · 1.31 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
45
46
47
48
49
// vite plugins
import ViteSvgSpriteWrapper from 'vite-svg-sprite-wrapper'
// utils
import { defineConfig } from 'vite'
import { resolve } from 'node:path'
const cwd = process.cwd()
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
plugins: [
ViteSvgSpriteWrapper({
icons: 'src/icons/**.svg',
outputDir: 'public/icons'
})
],
resolve: {
alias: {
'@': resolve(cwd, 'src')
}
},
build: {
rollupOptions: {
output: {
assetFileNames(chunkInfo) {
const ext = chunkInfo.name?.split('.').at(-1)
let type = ext
if (ext) {
if (/png|jpe?g|svg/i.test(ext)) {
type = 'images'
}
if (/css/i.test(ext)) {
type = 'styles'
}
}
return `${type}/[name][extname]`
},
chunkFileNames: 'scripts/[name].js',
entryFileNames: 'scripts/[name].js'
}
}
}
}
})