UNPKG

1.24 kBJavaScriptView Raw
1import ChildProcess from 'child_process';
2import { Packer, Watcher, Presser } from './packer.mjs';
3
4const Spawn = ChildProcess.spawn;
5
6(async function () {
7
8 const packOptions = { bundle: true, transform: true, name: 'Oxe', input: 'src/index.js', output: 'web/assets/oxe.js' };
9
10 await Packer(packOptions);
11
12 await Watcher('./src', async function () {
13 console.log('pack: start');
14 await Packer(packOptions);
15 console.log('pack: end');
16 });
17
18 const child = Spawn('muleify', [ '-ss', 'web' ], { detached: false, stdio: 'inherit' });
19
20 await Presser(
21 async function (key) {
22 switch (key) {
23 case 'p':
24 console.log('pack: start');
25 await Packer(packOptions);
26 console.log('pack: end');
27 break;
28 case 'e':
29 console.log('exit: start');
30 child.kill();
31 console.log('exit: end');
32 process.exit();
33 break;
34 }
35 },
36 async function () {
37 child.kill();
38 }
39 );
40
41 console.log('');
42 console.log('Presser - p: packs');
43 console.log('Presser - e: exits');
44
45}()).catch(console.error);