1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const {Compiler} = require('../build/compiler');
|
12 | const analyzer = require('bundle-analyzer');
|
13 |
|
14 | exports.run = async function profileHandler(
|
15 | {dir = '.', port, environment} /*: any */
|
16 | ) {
|
17 | const compiler = new Compiler({env: environment, dir, watch: true});
|
18 | const server = analyzer.start({
|
19 | dir: `${dir}/.fusion/dist/${environment}/client`,
|
20 | port,
|
21 | });
|
22 | const watcher = compiler.start(() => {
|
23 | server.update();
|
24 | });
|
25 | return {
|
26 | compiler,
|
27 | stop() {
|
28 | watcher.close();
|
29 | server.close();
|
30 | },
|
31 | };
|
32 | };
|