-
Notifications
You must be signed in to change notification settings - Fork 72
/
rollup.config.mjs
75 lines (69 loc) · 1.42 KB
/
rollup.config.mjs
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
import { readdirSync as readdir, statSync as stat } from 'fs';
import { join } from 'path';
function walk(root, result=[]) {
const rootURL = new URL(root, import.meta.url);
const paths = readdir(rootURL);
for (const path of paths) {
const stats = stat(new URL(path, rootURL));
if (stats.isDirectory()) {
walk(`${root}${path}/`, result);
}
else {
result.push({
input: join(root, path),
dir: join('dist/', root)
});
}
}
return result;
}
function walkLib(config) {
const files = walk('./lib/');
files.forEach(({input, dir}) => {
config.push({
input,
output: {
entryFileNames: '[name].js',
dir,
format: 'cjs',
preserveModules: true,
exports: 'auto'
},
external: [
'node:dgram',
'node:events',
'osc-min',
'jspack',
'#decode'
]
});
});
}
function walkTest(config) {
const tests = walk('./test/');
tests.forEach(({input, dir}) => {
config.push({
input,
plugins: [],
output: {
entryFileNames: '[name].js',
dir,
format: 'cjs',
exports: 'auto',
preserveModules: true
},
external: [
'node:dgram',
'node:net',
'node-osc',
'osc-min',
'tap',
'#decode'
]
});
});
}
const config = [];
walkLib(config);
walkTest(config);
export default config;