1 |
|
2 | process.env.BABEL_ENV = 'production';
|
3 | process.env.NODE_ENV = 'production';
|
4 | process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../configs/.browserslistrc');
|
5 |
|
6 |
|
7 |
|
8 | const { spawn } = require('child_process');
|
9 | const fs = require('fs-extra');
|
10 | const path = require('path');
|
11 |
|
12 | const checkRequiredFiles = require('../util/check-required-files');
|
13 | const configs = require('../../configs/app-configs');
|
14 |
|
15 | if (!checkRequiredFiles()) {
|
16 | process.exit(1);
|
17 | }
|
18 |
|
19 | if (fs.pathExistsSync(configs.serverOutputPath)) {
|
20 | fs.removeSync(configs.serverOutputPath);
|
21 | }
|
22 |
|
23 | const compileServer = spawn('node', [path.join(__dirname, './server')], { stdio: 'inherit' });
|
24 | const compileClient = spawn('node', [path.join(__dirname, './client')], { stdio: 'inherit' });
|
25 |
|
26 | const onProcessExit = (code) => {
|
27 | if (code !== 0) {
|
28 | compileServer.kill();
|
29 | compileClient.kill();
|
30 | process.exit(code);
|
31 | }
|
32 | };
|
33 |
|
34 |
|
35 | compileServer.on('close', onProcessExit);
|
36 | compileClient.on('close', onProcessExit);
|