forked from MylesBorins/node-osc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
71 lines (65 loc) · 1.32 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
import { readdirSync as readdir, statSync as stat } from 'fs';
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: `${root}${path}`,
dir: `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',
exports: 'auto'
},
preserveModules: true,
external: [
'dgram',
'events',
'osc-min',
'jspack'
]
});
});
}
function walkTest(config) {
const tests = walk('./test/');
tests.forEach(({input, dir}) => {
config.push({
input,
output: {
entryFileNames: '[name].js',
dir,
format: 'cjs',
exports: 'auto'
},
preserveModules: true,
external: [
'dgram',
'get-port',
'node-osc',
'osc-min',
'tap'
]
})
});
}
const config = [];
walkLib(config);
walkTest(config);
export default config;