qmzreact 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,8 +29,7 @@ module.exports = {
29
29
  compression: 'gzip',
30
30
  buildDependencies: {
31
31
  config: [
32
- './build.config.js',
33
- './babel.config.js'
32
+ './build.config.js'
34
33
  ]
35
34
  }
36
35
  },
@@ -45,8 +44,7 @@ module.exports = {
45
44
  name: 'local_development',
46
45
  buildDependencies: {
47
46
  config: [
48
- './build.config.js',
49
- './babel.config.js'
47
+ './build.config.js'
50
48
  ]
51
49
  }
52
50
  },
@@ -20,7 +20,7 @@ module.exports = [
20
20
  workerParallelJobs: 60,
21
21
 
22
22
  // 额外的 node.js 参数
23
- workerNodeArgs: ['--max-old-space-size=1024'],
23
+ workerNodeArgs: ['--max-old-space-size=2048'],
24
24
 
25
25
  // 允许重新生成一个僵死的 work 池
26
26
  // 这个过程会降低整体编译速度
@@ -7,6 +7,7 @@ var loaders = require('./loaders');
7
7
  var HtmlWebpackPlugin = require('html-webpack-plugin');
8
8
  var AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
9
9
  var fs = require('fs');
10
+
10
11
  var entry = [];
11
12
  var entryFile = ['./src/index.js', './src/index.jsx', './src/index.ts', './src/index.tsx'];
12
13
  for (var i = 0; i < entryFile.length; i++) {
@@ -18,6 +19,7 @@ for (var i = 0; i < entryFile.length; i++) {
18
19
  // continue to next candidate
19
20
  }
20
21
  }
22
+
21
23
  var plugins = [];
22
24
  if (processConfig.dll) {
23
25
  plugins = [
@@ -28,23 +28,43 @@ if (Array.isArray(processConfig.watch) && processConfig.watch.length > 0) {
28
28
  * 启动服务
29
29
  */
30
30
  module.exports = function startServer() {
31
- var spinner = ora();
32
- spinner.start()
33
- childProcess = spawn('node', ['--max_old_space_size=2048',path.join(__dirname, './dev-server.js'), ...process.argv.slice(2)]);
31
+ var spinner = ora('Starting dev server...');
32
+ spinner.start();
33
+ childProcess = spawn('node', ['--max_old_space_size=4096', path.join(__dirname, './dev-server.js'), ...process.argv.slice(2)]);
34
+
34
35
  // 监听子进程输出
35
36
  childProcess.stdout.on('data', (data) => {
37
+ // 保留原有输出
36
38
  console.group(`${data}`);
37
39
  console.groupEnd();
38
40
  });
39
-
41
+
42
+ // 从 stderr 解析进度并用 ora 显示
40
43
  childProcess.stderr.on('data', (data) => {
41
- if (data.toString().includes('100%')) {
42
- spinner.stop()
44
+ const str = data.toString();
45
+ // 匹配百分比,如 "45%" 或 "100%"
46
+ const m = str.match(/(\d{1,3})%/);
47
+ if (m) {
48
+ const pct = m[1];
49
+ spinner.text = `Building ${pct}%`;
50
+ if (pct === '100' || str.includes('100%')) {
51
+ spinner.succeed('Build 100%');
52
+ if (spinner.isSpinning) spinner.stop();
53
+ }
54
+ return;
55
+ }
56
+ if (str.includes('100%')) {
57
+ spinner.succeed('Build 100%');
58
+ if (spinner.isSpinning) spinner.stop();
59
+ }
60
+ // 捕获错误等信息并显示
61
+ if (/error/i.test(str)) {
62
+ spinner.fail(str.split(/\r?\n/)[0]);
43
63
  }
44
64
  });
45
-
46
- childProcess.on('close', (code) => {
47
- spinner.stop();
48
- console.log(`======= Service Closed ======`);
65
+
66
+ childProcess.on('close', (exitCode) => {
67
+ if (spinner.isSpinning) spinner.stop();
68
+ console.log(`======= Service Closed (code: ${exitCode}) ======`);
49
69
  });
50
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmzreact",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "前端react本地启动服务和打包工具",
5
5
  "author": {
6
6
  "name": "qmz",