-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
87 lines (78 loc) · 2.01 KB
/
build.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
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
import {defineConfig, mergeConfig, build} from 'vite';
import fs from 'fs';
let pkg = JSON.parse(fs.readFileSync('package.json', {encoding:'utf8'}));
let banner = `/**
* ${pkg.name} ${pkg.version}
* Copyright (C) 2023 ActiveWidgets SARL. All Rights Reserved.
* This code is licensed under the MIT license found in the
* LICENSE file in the root directory of this package.
*/
`;
let base = defineConfig({
configFile: false,
build: {
outDir: 'dist',
emptyOutDir: false,
sourcemap: true,
reportCompressedSize: false,
lib : {
entry: 'src/index.js',
formats: ['es']
},
rollupOptions: {
external: [
'preact',
'preact/compat',
'@activewidgets/frameworks/preact',
'@activewidgets/datagrid/index.js',
'@activewidgets/datagrid/style-inject',
'@activewidgets/ui/index.js',
'@activewidgets/ui/style-inject'
]
}
},
esbuild: {
banner
}
});
await build(mergeConfig(base, defineConfig({
build: {
emptyOutDir: true,
lib: {
fileName: 'main'
},
rollupOptions: {
external: [
'@activewidgets/datagrid',
'@activewidgets/ui'
]
}
}
})));
await build(mergeConfig(base, defineConfig({
publicDir: './css',
build: {
lib: {
fileName: 'index'
}
},
resolve: {
alias: {
'@activewidgets/datagrid': '@activewidgets/datagrid/index.js',
'@activewidgets/ui': '@activewidgets/ui/index.js'
}
}
})));
await build(mergeConfig(base, defineConfig({
build: {
lib: {
fileName: 'style-inject'
}
},
resolve: {
alias: {
'@activewidgets/datagrid': '@activewidgets/datagrid/style-inject',
'@activewidgets/ui': '@activewidgets/ui/style-inject',
}
}
})));