-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
96 lines (94 loc) · 2.98 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
87
88
89
90
91
92
93
94
95
96
import {resolve} from "path";
import {defineConfig} from "vite";
import vue from '@vitejs/plugin-vue';
const config = {
stellar: {
plugins: [
vue()
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
server: {
fs: {
allow: [".."],
},
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'stellar-ui',
formats: ['es'], // adding 'umd' requires globals set to every external module
fileName: (format) => `stellar-ui.${format}.js`,
},
rollupOptions: {
// external modules won't be bundled into your library
external: ['vue', /@popperjs\/.+/], // not every external has a global
output: {
preserveModules: true,
inlineDynamicImports: false,
// disable warning on src/index.ts using both default and named export
exports: 'named',
// Provide global variables to use in the UMD build
// for externalized deps (not useful if 'umd' is not in lib.formats)
globals: {
vue: 'Vue',
},
},
},
emptyOutDir: false,
},
},
// **
// Helpers
// **
helpers: {
plugins: [
vue()
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
server: {
fs: {
allow: [".."],
},
},
build: {
lib: {
entry: resolve(__dirname, "./src/helpers.ts"),
name: 'helpers',
formats: ['es', "cjs"],
fileName: (format) => `helpers.${format}.js`,
},
rollupOptions: {
// external modules won't be bundled into your library
external: ['vue', /@popperjs\/.+/], // not every external has a global
output: {
preserveModules: true,
inlineDynamicImports: false,
// disable warning on src/index.ts using both default and named export
exports: 'named',
// Provide global variables to use in the UMD build
// for externalized deps (not useful if 'umd' is not in lib.formats)
globals: {
vue: 'Vue',
},
},
},
emptyOutDir: false,
},
},
};
console.log(`LIB_NAME: ${process.env.LIB_NAME}`);
const currentConfig = config[process.env.LIB_NAME];
if (currentConfig === undefined) {
throw new Error('LIB_NAME is not defined or is not valid');
}
export default defineConfig({
...currentConfig
});