-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
56 lines (48 loc) · 1.24 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
50
51
52
53
54
55
56
import { redBright } from "colorette"
import { defineConfig } from 'vite'
class ConfigHandler {
constructor() {
this.mode = null;
/**
* Add as many Map elements as you want configs
* The key value represents the config flag
*
*/
this.configList = new Map()
.set('dev', Configs.dev())
.set('library', Configs.library())
}
get(value) {
const config = this.configList.get(value);
if (!config) {
console.log(redBright('The config mode flag does not exist'));
process.exit();
}
return config;
}
}
class Configs {
static dev() {
return {}
}
static library() {
return {
build: {
lib: {
entry: 'src/main.ts',
name: 'MyLib',
formats: ['es'],
},
rollupOptions: {
output: {
preserveModules: true
}
},
minify: false
}
}
}
}
const arg = process.env.npm_config_mode;
const config = new ConfigHandler();
export default defineConfig(config.get(arg));