-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
86 lines (82 loc) · 1.85 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
74
75
76
77
78
79
80
81
82
83
84
85
86
/// <reference types="vitest" />
import * as path from 'path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Unocss from 'unocss/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { viteSingleFile } from './utils/vite_build_single_file'
import { obfuscator } from 'rollup-obfuscator';
const config = {
ui: {
input: {
main: path.resolve(__dirname, 'index.html'),
},
output: {
entryFileNames: 'assets/[name].js',
},
},
hook: {
input: {
masterGo: path.resolve(__dirname, './masterGo/code.ts'),
},
output: {
dir: path.resolve(__dirname, './.appscript'),
entryFileNames: 'code.js',
},
},
}
const LIB_NAME = process.env.LIB_NAME || 'ui'
const currentConfig = config[LIB_NAME]
if (currentConfig === undefined)
throw new Error('LIB_NAME is not defined or is not valid')
export default defineConfig({
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`,
},
},
define: {
'import.meta.vitest': 'false',
},
plugins: process.env.TEST
? []
: [
Vue(
{
reactivityTransform: true,
},
),
Unocss(),
AutoImport({
imports: [
'vue',
'@vueuse/core',
],
dts: true,
}),
Components({
resolvers: [NaiveUiResolver()],
dts: true,
}),
viteSingleFile(),
obfuscator(),
],
build: {
assetsInlineLimit: 1000000000000000,
rollupOptions: {
...currentConfig,
emptyOutDir: false,
},
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
},
},
},
server: {
host: '0.0.0.0',
},
})