-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
53 lines (51 loc) · 1.79 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
import { resolve } from 'path'
import { defineConfig, Rollup } from 'vite'
import vue from '@vitejs/plugin-vue'
import unocss from 'unocss/vite'
import { vitePluginFakeServer } from 'vite-plugin-fake-server'
import { vitePluginPrintUrls } from './plugins/vite-plugin-print-urls'
// 各种资源的整理
const assetFileNames = (chunkInfo: Rollup.PreRenderedAsset) => {
let ext = chunkInfo.name.split('.').pop()
// 将各种图片, 字体分别归为一类, 其余的作为一类
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(ext)) {
ext = 'images'
} else if (/woff|woff2/i.test(ext)) {
ext = 'fonts'
}
return `assets/${ext}/[name].[hash][extname]`
}
const fileNames = 'assets/js/[name].[hash].js'
// https://vitejs.dev/config/
export default defineConfig({
define: {
// vue-i18n csp issue fixed
// https://vue-i18n.intlify.dev/guide/advanced/optimization#jit-compilation
// https://github.com/intlify/vue-i18n-next/issues/1457
__INTLIFY_JIT_COMPILATION__: true
},
plugins: [vue(), unocss(), vitePluginFakeServer(), vitePluginPrintUrls()],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@assets': resolve(__dirname, './src/assets'),
'@common': resolve(__dirname, './src/common'),
'@popup': resolve(__dirname, './src/popup'),
'@option': resolve(__dirname, './src/option')
}
},
build: {
emptyOutDir: true,
rollupOptions: {
input: {
popup: resolve(__dirname, 'popup.html'),
option: resolve(__dirname, 'option.html')
},
output: {
assetFileNames,
chunkFileNames: fileNames,
entryFileNames: fileNames
}
}
}
})