-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
73 lines (70 loc) · 1.65 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
73
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { resolve } from 'path'
import hotReloadBackground from './scripts/hot-reload/background'
import { __DEV__, outputDir } from './const'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {
ElementPlusResolver,
NaiveUiResolver
} from 'unplugin-vue-components/resolvers'
export const r = (...args: string[]) => resolve(__dirname, '.', ...args)
export const commonConfig = {
root: r('src'),
define: {
__DEV__
},
resolve: {
alias: {
'~/': `${r('src')}/`
}
},
plugins: [
Vue(),
UnoCSS(),
AutoImport({
resolvers: [ElementPlusResolver()],
dts: 'typings/auto-import.d.ts',
imports: [
'vue',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar'
]
}
]
}),
Components({
resolvers: [ElementPlusResolver(), NaiveUiResolver()],
dts: 'typings/components.d.ts',
})
]
}
export default defineConfig({
...commonConfig,
build: {
watch: __DEV__ ? {} : null,
cssCodeSplit: false,
emptyOutDir: false,
sourcemap: false,
outDir: r(outputDir),
rollupOptions: {
input: {
background: r('src/background/index.ts'),
popup: r('src/popup/index.ts')
},
output: {
assetFileNames: '[name].[ext]',
entryFileNames: '[name]/index.js',
extend: true,
format: 'es'
}
}
},
plugins: [...commonConfig.plugins, hotReloadBackground()]
})