dev.js
1003 Bytes
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
import { watch } from 'rollup';
import { getRollupConfigs } from './buildBase.js';
async function dev() {
const configs = await getRollupConfigs();
for (const name of Object.keys(configs)) {
const config = configs[name];
const watcher = watch(
config.output.map((o) => ({
input: config.input,
plugins: [...config.plugins],
external: config.external,
output: o,
watch: config.watch,
})),
);
watcher.on('event', (event) => {
switch (event.code) {
case 'BUNDLE_END': {
console.log(`打包完成: ${name}`);
break;
}
case 'BUNDLE_START': {
console.log(`开始打包: ${name}`);
break;
}
case 'ERROR': {
console.error(`打包失败: ${name}`, event.error);
break;
}
case 'START': {
console.log(`开始监听: ${name}`);
break;
}
// No default
}
});
}
}
dev();