-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.ts
72 lines (69 loc) · 1.94 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
60
61
62
63
64
65
66
67
68
69
70
71
72
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import svgLoader from 'vite-svg-loader'
import vueJsx from '@vitejs/plugin-vue-jsx'
const INVALID_CHAR_REGEX = /[_\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g
const DRIVE_LETTER_REGEX = /^[a-z]:/i
function sanitizeFileName(name: string): string {
const match = DRIVE_LETTER_REGEX.exec(name)
const driveLetter = match ? match[0] : ''
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
return driveLetter + name.substring(driveLetter.length).replace(INVALID_CHAR_REGEX, '')
}
// https://vitejs.dev/config/
export default defineConfig({
css: { preprocessorOptions: { scss: { charset: false } } },
server: {
host: '0.0.0.0',
port: 3000,
},
build: {
rollupOptions: {
output: {
compact: true,
sanitizeFileName(fileName) {
return sanitizeFileName(fileName)
},
assetFileNames(assetInfo) {
const extType = assetInfo.name?.split('.')?.at(1) ?? ''
if (/woff2|woff|ttf/i.test(extType)) {
return 'assets/[name][extname]'
}
return 'assets/[name]-[hash][extname]'
},
},
},
},
esbuild: { legalComments: 'none' },
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('md-'),
},
},
}),
vueJsx(),
svgLoader(),
Components({
resolvers: [IconsResolver()],
}),
Icons(),
],
define: {
'process.env': {},
__VUE_I18N_FULL_INSTALL__: true,
__VUE_I18N_LEGACY_API__: false,
__INTLIFY_PROD_DEVTOOLS__: false,
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
})