forked from umijs/umi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
53 lines (49 loc) · 1.25 KB
/
ui.js
File metadata and controls
53 lines (49 loc) · 1.25 KB
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
const { fork } = require('child_process');
const { join } = require('path');
const UMI_BIN = join(__dirname, '../packages/umi/bin/umi.js');
function buildUIApp(opts = {}) {
console.log(`Build ui app`);
const { watch } = opts;
const child = fork(UMI_BIN, [watch ? 'dev' : 'build', ...(watch ? ['--watch'] : [])], {
env: {
APP_ROOT: './packages/umi-ui/client',
UMI_UI: 'none',
},
});
process.on('SIGINT', () => {
child.kill('SIGINT');
});
}
function buildPlugins(roots, opts = {}) {
return roots.map(root => {
console.log(`Build for ${root}`);
const { watch } = opts;
return require('father-build/lib/build').build({
cwd: join(__dirname, '..', root),
watch,
});
});
}
(async () => {
const watch = process.argv.includes('-w') || process.argv.includes('--watch');
try {
await Promise.all(
buildPlugins(
[
'packages/umi-plugin-ui/src/plugins/dashboard',
'packages/umi-plugin-ui/src/plugins/blocks',
'packages/umi-plugin-ui/src/plugins/configuration',
],
{
watch,
},
),
);
} catch (e) {
console.error('Build plugins failed', e);
}
console.log('Build for plugins done');
buildUIApp({
watch,
});
})();