-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
69 lines (56 loc) · 1.87 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
import { resolve } from 'path';
import git from 'git-rev-sync';
import { defineConfig, UserConfigExport } from 'vite';
// import { visualizer } from 'rollup-plugin-visualizer';
const root = resolve(__dirname, 'source');
const outDir = resolve(__dirname, 'dist');
export default defineConfig(({ mode }) => {
const config: UserConfigExport = {
root,
build: {
outDir,
lib: {
entry: resolve(root, 'index.ts'),
name: 'haeley-template',
formats: ['cjs', 'umd', 'es'],
// fileName: (format: ModuleFormat): string => format === 'umd' ? 'index.js' : `haeley-template.${format}.js`
},
sourcemap: 'hidden',
// rollupOptions: {
// external: ['rxjs'],
// output: {
// globals: {
// rxjs: 'rxjs'
// }
// }
// }
},
define: {
__GIT_COMMIT__: JSON.stringify(git.short(__dirname)),
__GIT_BRANCH__: JSON.stringify(git.branch(__dirname)),
__LIB_NAME__: JSON.stringify(process.env.npm_package_name),
__LIB_VERSION__: JSON.stringify(process.env.npm_package_version),
},
// plugins: [visualizer()]
};
// switch (command) {
// case 'serve':
// break;
// case 'build':
// default:
// break;
// }
switch (mode) {
case 'development':
config.build.outDir = outDir;
break;
case 'production':
default:
config.build.emptyOutDir = true;
// config.define.__DISABLE_ASSERTIONS__ = JSON.stringify(true);
// config.define.__LOG_VERBOSITY_THRESHOLD__ = JSON.stringify(2);
break;
}
console.log(config);
return config;
});