@qse/edu-scripts 1.13.1 → 1.13.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.13.3 (2023-04-06)
4
+
5
+ - fix: 锁定 webpack 版本
6
+
7
+ ## 1.13.2 (2023-02-01)
8
+
9
+ - fix: 修复部署日志错误
10
+
11
+ ## 1.13.1 (2023-02-01)
12
+
13
+ - feat: 优化日志格式
14
+ - feat: 部署时清理 `ver.js` 里杂乱的 `comments`
15
+
3
16
  ## 1.13.0 (2022-11-10)
4
17
 
5
18
  - feat: 教育集成项目部署增加日志功能
package/docs/override.md CHANGED
@@ -126,18 +126,24 @@ module.exports = defineConfig({
126
126
  if (max) {
127
127
  var scale = 1
128
128
  var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/)
129
- var isMobile = /iphone|ipad|ipod|Windows Phone|andriod/i.test(navigator.userAgent)
129
+ var isMobile = /iphone|ipad|ipod|Windows Phone|android/i.test(navigator.userAgent)
130
130
  if (match && isMobile) {
131
131
  scale = parseFloat(match[1])
132
132
  }
133
- var maxFontSize = max / scale
133
+ maxFontSize = max / scale
134
134
  }
135
135
 
136
- docEl.style.fontSize = Math.min((docEl.clientWidth / designWidth) * base, maxFontSize) + 'px'
136
+ var clientWidth = docEl.clientWidth ? docEl.clientWidth : docEl.getBoundingClientRect().width
137
+
138
+ docEl.style.setProperty(
139
+ 'font-size',
140
+ Math.min((clientWidth / designWidth) * base, maxFontSize) + 'px',
141
+ 'important'
142
+ )
137
143
  }
138
144
  resize()
139
145
  window.addEventListener('resize', resize)
140
- })(375, 16)
146
+ })(375, 16, 16)
141
147
  </script>
142
148
  ```
143
149
 
package/docs/static.md CHANGED
@@ -8,7 +8,7 @@
8
8
  <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/antd3.26.20.js"></script>
9
9
 
10
10
  <!-- 下方资源可能存在版本滞后 -->
11
- <!-- @qsb/antd @1.5.4 -->
11
+ <!-- @qsb/antd @1.7.2 -->
12
12
  <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/qsb-antd.min.js"></script>
13
13
  <!-- @qsb/scheme-render @1.2.3 -->
14
14
  <script src="//www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/qsb-scheme-render.min.js"></script>
@@ -1,33 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs-extra');
4
-
5
4
  const paths = require('./config/paths');
6
-
7
5
  const path = require('path');
8
-
9
6
  const chalk = require('chalk');
10
-
11
7
  const pkg = require('../package.json');
12
-
13
8
  const glob = require('globby');
14
-
15
9
  const ora = require('ora');
16
-
17
10
  const {
18
11
  prompt
19
12
  } = require('inquirer');
20
-
21
13
  const open = require('open');
14
+
22
15
  /**
23
16
  * @param {string} msg
24
17
  * @param {(spinner:ora.Ora) => void | Promise<void>} callback
25
18
  */
26
-
27
-
28
19
  async function step(msg, callback) {
29
20
  const spinner = ora(msg).start();
30
-
31
21
  try {
32
22
  await callback(spinner);
33
23
  spinner.succeed();
@@ -36,16 +26,13 @@ async function step(msg, callback) {
36
26
  throw error;
37
27
  }
38
28
  }
39
-
40
29
  module.exports = async function autoRefactor() {
41
30
  if (await fs.pathExists(paths.public)) {
42
31
  console.log(chalk.green('已完成改造,不需要重复执行,如果运行报错请查看文档'));
43
32
  console.log(`文档: ${chalk.underline(pkg.homepage)}`);
44
33
  process.exit(0);
45
34
  }
46
-
47
35
  const appPkg = require(paths.package);
48
-
49
36
  const answers = await prompt([{
50
37
  type: 'input',
51
38
  name: 'name',
@@ -103,7 +90,6 @@ module.exports = async function autoRefactor() {
103
90
  const HTMLFiles = await glob('*.html', {
104
91
  cwd: paths.src
105
92
  });
106
-
107
93
  for (const file of HTMLFiles) {
108
94
  await fs.move(path.resolve(paths.src, file), path.resolve(paths.public, file));
109
95
  }
@@ -115,7 +101,6 @@ module.exports = async function autoRefactor() {
115
101
  });
116
102
  await step('删除没用的 babel 和 webpack 配置', async () => {
117
103
  const deleteFiles = [...(await glob('{.,*}babel*')), ...(await glob('*webpack*')), ...(await glob('package-lock.json')), paths.nodeModules, paths.sshSftp];
118
-
119
104
  for (const filePath of deleteFiles) {
120
105
  await fs.remove(filePath);
121
106
  }
@@ -132,14 +117,12 @@ module.exports = async function autoRefactor() {
132
117
  scripts.start = 'edu-scripts start';
133
118
  scripts.build = 'edu-scripts build';
134
119
  scripts.analyze = 'edu-scripts build --analyze';
135
-
136
120
  if (answers.mode !== 'single') {
137
121
  scripts.deploy = `edu-scripts deploy ${answers.deploy.join(' ')}`;
138
122
  } else {
139
123
  scripts.deploy = `edu-scripts deploy`;
140
124
  scripts['commit-dist'] = 'edu-scripts commit-dist --rm-local';
141
125
  }
142
-
143
126
  scripts['one-key-deploy'] = 'npm version patch';
144
127
  scripts.postversion = 'npm run build && npm run deploy';
145
128
  });
package/lib/build.js CHANGED
@@ -3,47 +3,33 @@
3
3
  process.env.NODE_ENV = 'production';
4
4
  process.env.BABEL_ENV = 'production';
5
5
  process.env.BROWSERSLIST = '>0.25%, not dead, not op_mini all';
6
-
7
6
  const webpack = require('webpack');
8
-
9
7
  const chalk = require('chalk');
10
-
11
8
  const getConfig = require('./utils/getConfig');
12
-
13
9
  const {
14
10
  measureFileSizesBeforeBuild,
15
11
  printFileSizesAfterBuild
16
12
  } = require('./utils/FileSizeReporter');
17
-
18
13
  const paths = require('./config/paths');
19
-
20
14
  const fs = require('fs-extra');
21
-
22
15
  const appConfig = require('./utils/appConfig');
23
-
24
16
  const WARN_AFTER_BUNDLE_GZIP_SIZE = appConfig.single ? 1024 * 1024 : 30 * 1024;
25
17
  const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
26
-
27
18
  module.exports = async function build(args) {
28
19
  if (args.analyze) {
29
20
  process.env.ANALYZE = '1';
30
21
  }
31
-
32
22
  if (args.outputHtml) {
33
23
  process.env.OUTPUT_HTML = '1';
34
24
  }
35
-
36
25
  const previousSizeMap = await measureFileSizesBeforeBuild(paths.dist);
37
26
  fs.emptyDirSync(paths.dist);
38
-
39
27
  if (appConfig.single) {
40
28
  fs.copySync(paths.public, paths.resolveApp('dist'));
41
29
  }
42
-
43
30
  if (appConfig.mainProject && fs.existsSync(paths.static)) {
44
31
  fs.copySync(paths.static, paths.resolveApp('dist', 'static'));
45
32
  }
46
-
47
33
  webpack(getConfig(args), (error, stats) => {
48
34
  if (error) {
49
35
  console.log(chalk.red('编译失败'));
@@ -51,7 +37,6 @@ module.exports = async function build(args) {
51
37
  console.log();
52
38
  process.exit(1);
53
39
  }
54
-
55
40
  if (stats.compilation.errors.length) {
56
41
  console.log(chalk.red('编译失败'));
57
42
  console.log(stats.toString({
@@ -61,7 +46,6 @@ module.exports = async function build(args) {
61
46
  }));
62
47
  process.exit(1);
63
48
  }
64
-
65
49
  console.log(stats.toString({
66
50
  colors: true,
67
51
  preset: 'errors-warnings',
@@ -71,13 +55,11 @@ module.exports = async function build(args) {
71
55
  console.log('gzip 后文件大小:\n');
72
56
  printFileSizesAfterBuild(stats, previousSizeMap, paths.dist, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
73
57
  console.log();
74
-
75
58
  if (appConfig.single) {
76
59
  console.log(`打包完成,可以使用 ${chalk.green('@qse/ssh-sftp')} 自动部署代码到 v1`);
77
60
  } else {
78
61
  console.log(`打包完成,可以运行 ${chalk.green('npx edu-scripts deploy')} 部署代码到 v1`);
79
62
  }
80
-
81
63
  console.log();
82
64
  });
83
65
  };
package/lib/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- const pkg = require('../package.json'); // 检查运行条件
5
-
6
-
7
- require('./utils/beforeStart'); // eslint-disable-next-line no-unused-expressions
4
+ const pkg = require('../package.json');
8
5
 
6
+ // 检查运行条件
7
+ require('./utils/beforeStart');
9
8
 
9
+ // eslint-disable-next-line no-unused-expressions
10
10
  require('yargs').usage(`教育工程化 webpack5 基础框架\n文档: ${pkg.homepage}`).command('start', '开发', yargs => yargs.option('port', {
11
11
  alias: 'p',
12
12
  desc: '指定端口'
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  const chalk = require('chalk');
4
-
5
4
  const paths = require('./config/paths');
6
-
7
5
  const fs = require('fs-extra');
8
-
9
6
  const exec = (cmd, opts) => require('child_process').execSync(cmd, {
10
7
  encoding: 'utf-8',
11
8
  stdio: 'pipe',
12
9
  ...opts
13
10
  });
14
-
15
11
  const tmp = require('tmp');
16
-
17
12
  function validateSVNRoot(root) {
18
13
  const ls = exec(`svn ls ${root}`);
19
14
  return ['trunk', 'branches'].every(s => ls.includes(s));
20
15
  }
21
-
22
16
  function getWorkingCopyInfo() {
23
17
  exec(`svn up`);
24
18
  const url = exec(`svn info --show-item url`).trim();
@@ -26,20 +20,16 @@ function getWorkingCopyInfo() {
26
20
  const author = exec(`svn info --show-item last-changed-author`).trim();
27
21
  let branch = 'trunk';
28
22
  let root = url.replace(/\/trunk$/, '');
29
-
30
23
  if (url.includes('/branches/')) {
31
24
  branch = url.split('/').pop();
32
25
  root = url.replace(/\/branches\/[^/]+$/, '');
33
26
  }
34
-
35
27
  let distBranchURL = root + '/branches/dist';
36
28
  let distBranchDirURL = distBranchURL + '/' + branch;
37
-
38
29
  if (!validateSVNRoot(root)) {
39
30
  console.log(chalk.red('SVN目录不符合规则,必须包含 trunk branches'));
40
31
  process.exit(1);
41
32
  }
42
-
43
33
  return {
44
34
  url,
45
35
  branch,
@@ -50,10 +40,8 @@ function getWorkingCopyInfo() {
50
40
  root
51
41
  };
52
42
  }
53
-
54
43
  function copyDistToRepo(info) {
55
44
  const tmpdir = tmp.dirSync().name;
56
-
57
45
  try {
58
46
  exec(`svn ls ${info.distBranchDirURL} --depth empty`);
59
47
  } catch (error) {
@@ -63,15 +51,12 @@ function copyDistToRepo(info) {
63
51
  throw error;
64
52
  }
65
53
  }
66
-
67
54
  exec(`svn co ${info.distBranchDirURL} ${tmpdir}`);
68
-
69
55
  try {
70
56
  exec(`svn rm * --force -q`, {
71
57
  cwd: tmpdir
72
58
  });
73
59
  } catch (error) {}
74
-
75
60
  fs.copySync(paths.dist, tmpdir);
76
61
  exec(`svn add * --force --auto-props --parents --depth infinity -q`, {
77
62
  cwd: tmpdir
@@ -82,32 +67,27 @@ function copyDistToRepo(info) {
82
67
  });
83
68
  fs.removeSync(tmpdir);
84
69
  }
70
+
85
71
  /**
86
72
  * svn commit dist folder to dish branches
87
73
  *
88
74
  * @param {Object} args
89
75
  * @param {boolean} args.rmLocal
90
76
  */
91
-
92
-
93
77
  module.exports = async function commitDist(args) {
94
78
  if (!fs.existsSync(paths.dist)) {
95
79
  console.log(chalk.red('未找到 dist 文件夹,请先 edu-scpirts build'));
96
80
  process.exit(1);
97
81
  }
98
-
99
82
  if (exec('svn st').trim().length) {
100
83
  console.log(chalk.red('似乎存在未提交的代码,请提交后重试。运行 svn st 查看具体信息'));
101
84
  process.exit(1);
102
85
  }
103
-
104
86
  const info = getWorkingCopyInfo();
105
87
  console.log(chalk.green([`分支: ${info.branch}`, `版本: ${info.revision}`, `作者: ${info.author}`, `地址: ${info.distBranchDirURL}`].join('\n')));
106
88
  copyDistToRepo(info);
107
-
108
89
  if (args.rmLocal) {
109
90
  fs.removeSync(paths.dist);
110
91
  }
111
-
112
92
  console.log(chalk.green('提交完成'));
113
93
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const getOverride = require('../utils/getOverride');
4
+
4
5
  /**
5
6
  * @typedef {Object} Opts
6
7
  * @property {string} [modules]
@@ -8,8 +9,6 @@ const getOverride = require('../utils/getOverride');
8
9
  * @param {Opts} [opts]
9
10
  * @return {*}
10
11
  */
11
-
12
-
13
12
  module.exports = function getBabelConfig(opts = {}) {
14
13
  const isDev = process.env.NODE_ENV === 'development';
15
14
  let config = {
@@ -35,11 +34,11 @@ module.exports = function getBabelConfig(opts = {}) {
35
34
  // explicitly resolving to match the provided helper functions.
36
35
  // https://github.com/babel/babel/issues/10261
37
36
  version: require('@babel/runtime/package.json').version,
38
- regenerator: true // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
37
+ regenerator: true
38
+ // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
39
39
  // // We should turn this on once the lowest version of Node LTS
40
40
  // // supports ES Modules.
41
41
  // useESModules: true,
42
-
43
42
  }], ['import', {
44
43
  libraryName: 'lodash',
45
44
  libraryDirectory: '',
@@ -47,10 +46,8 @@ module.exports = function getBabelConfig(opts = {}) {
47
46
  }, 'lodash']].filter(Boolean)
48
47
  };
49
48
  const override = getOverride();
50
-
51
49
  if (override.babel) {
52
50
  config = override.babel(config, 'node_modules') || config;
53
51
  }
54
-
55
52
  return config;
56
53
  };
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs');
4
-
5
4
  const paths = require('./paths');
6
-
7
5
  const appConfig = require('../utils/appConfig');
8
-
9
6
  const getOverride = require('../utils/getOverride');
10
-
11
7
  const hasJsxRuntime = (() => {
12
8
  try {
13
9
  require.resolve('react/jsx-runtime');
14
-
15
10
  return true && appConfig.single;
16
11
  } catch (error) {
17
12
  return false;
18
13
  }
19
14
  })();
15
+
20
16
  /**
21
17
  * @typedef {Object} Opts
22
18
  * @property {string} [modules]
@@ -24,8 +20,6 @@ const hasJsxRuntime = (() => {
24
20
  * @param {Opts} [opts]
25
21
  * @return {*}
26
22
  */
27
-
28
-
29
23
  module.exports = function getBabelConfig(opts = {}) {
30
24
  const isTypeScriptEnabled = fs.existsSync(paths.tsconfig);
31
25
  const isDev = process.env.NODE_ENV === 'development';
@@ -53,11 +47,11 @@ module.exports = function getBabelConfig(opts = {}) {
53
47
  // explicitly resolving to match the provided helper functions.
54
48
  // https://github.com/babel/babel/issues/10261
55
49
  version: require('@babel/runtime/package.json').version,
56
- regenerator: true // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
50
+ regenerator: true
51
+ // // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
57
52
  // // We should turn this on once the lowest version of Node LTS
58
53
  // // supports ES Modules.
59
54
  // useESModules: true,
60
-
61
55
  }], ['@babel/plugin-proposal-decorators', {
62
56
  legacy: true
63
57
  }], ['@babel/plugin-proposal-class-properties', {
@@ -73,10 +67,8 @@ module.exports = function getBabelConfig(opts = {}) {
73
67
  }, 'lodash'], isDev && 'react-refresh/babel'].filter(Boolean)
74
68
  };
75
69
  const override = getOverride();
76
-
77
70
  if (override.babel) {
78
71
  config = override.babel(config, 'src') || config;
79
72
  }
80
-
81
73
  return config;
82
74
  };
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  const path = require('path');
4
-
5
4
  const fs = require('fs');
6
-
7
5
  const glob = require('globby');
8
-
9
6
  function resolveApp(...filePath) {
10
7
  return path.resolve(process.cwd(), ...filePath);
11
8
  }
12
-
13
9
  function getExistPath(...paths) {
14
10
  for (const path of paths) {
15
11
  if (fs.existsSync(path)) {
16
12
  return path;
17
13
  }
18
14
  }
19
-
20
15
  return paths[0];
21
16
  }
22
-
23
17
  const paths = {
24
18
  resolveApp,
25
19
  eduAppEnv: resolveApp('src', 'edu-app-env.d.ts'),
@@ -2,21 +2,18 @@
2
2
 
3
3
  const vars = ['safe-area-inset-top', 'safe-area-inset-bottom', 'safe-area-inset-left', 'safe-area-inset-right'];
4
4
  const expr = new RegExp(`env\\(\\s*(${vars.join('|')})\\s*,?\\s*([^)]+)?\\s*\\)`, 'g');
5
- /** @type {import('postcss').PluginCreator} */
6
5
 
6
+ /** @type {import('postcss').PluginCreator} */
7
7
  module.exports = () => {
8
8
  return {
9
9
  postcssPlugin: 'postcss-safe-area',
10
-
11
10
  Declaration(decl) {
12
11
  const fallback = decl.value.replace(expr, (match, param, defaultValue) => defaultValue || '0');
13
-
14
12
  if (fallback !== decl.value) {
15
13
  decl.cloneBefore({
16
14
  value: fallback
17
15
  });
18
16
  }
19
17
  }
20
-
21
18
  };
22
19
  };
@@ -1,31 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs');
4
-
5
4
  const webpack = require('webpack');
6
-
7
5
  const HtmlWebpackPlugin = require('html-webpack-plugin');
8
-
9
6
  const {
10
7
  BundleAnalyzerPlugin
11
8
  } = require('webpack-bundle-analyzer');
12
-
13
9
  const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
14
-
15
10
  const paths = require('./paths');
16
-
17
11
  const TerserPlugin = require('terser-webpack-plugin');
18
-
19
12
  const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
20
-
21
13
  const appPkg = require(paths.package);
22
-
23
14
  const appConfig = require('../utils/appConfig');
24
-
25
15
  const {
26
16
  ESBuildMinifyPlugin
27
17
  } = require('esbuild-loader');
28
-
29
18
  const jsMainPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.name}` : `${appPkg.name}/${appPkg.name}`;
30
19
  const assetPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.version}` : `${appPkg.name}/${appPkg.version}`;
31
20
  const cssRegex = /\.css$/;
@@ -33,15 +22,12 @@ const cssModuleRegex = /\.module\.css$/;
33
22
  const lessRegex = /\.less$/;
34
23
  const lessModuleRegex = /\.module\.less$/;
35
24
  const imageInlineSizeLimit = 10 * 1024;
36
-
37
25
  const qseCDN = (() => {
38
26
  const contents = paths.indexHTML.map(url => fs.readFileSync(url, 'utf-8'));
39
-
40
27
  function include(pattern) {
41
28
  const regexp = new RegExp(pattern);
42
29
  return contents.some(content => regexp.test(content));
43
30
  }
44
-
45
31
  return {
46
32
  isUseCommon: include(/react16.14.*_common31?.js|react-dev-preset.js/),
47
33
  isUseAxios: include(/react16.14.*_axios0.21.1|react-dev-preset.js/),
@@ -51,18 +37,17 @@ const qseCDN = (() => {
51
37
  isUseQsbSchemeRender: include('qsb-scheme-render.min.js')
52
38
  };
53
39
  })();
40
+
54
41
  /**
55
42
  * @param {*} args
56
43
  * @param {import('../utils/defineConfig').Config} override
57
44
  */
58
-
59
-
60
45
  module.exports = function getWebpackConfig(args, override) {
61
46
  var _override$pure_funcs, _override$pure_funcs2;
62
-
63
47
  const isDev = process.env.NODE_ENV === 'development';
64
- const isProd = process.env.NODE_ENV === 'production'; // common function to get style loaders
48
+ const isProd = process.env.NODE_ENV === 'production';
65
49
 
50
+ // common function to get style loaders
66
51
  const getStyleLoaders = (cssOptions, preProcessor) => {
67
52
  const loaders = [{
68
53
  loader: 'style-loader',
@@ -91,14 +76,13 @@ module.exports = function getWebpackConfig(args, override) {
91
76
  }), fs.existsSync(paths.tailwind) && 'tailwindcss', 'postcss-flexbugs-fixes', ['postcss-preset-env', {
92
77
  autoprefixer: {
93
78
  flexbox: 'no-2009'
94
- } // https://preset-env.cssdb.org/features/#stage-2
95
-
79
+ }
80
+ // https://preset-env.cssdb.org/features/#stage-2
96
81
  }], isProd && require('./plugins/postcss-safe-area')(), isProd && ['postcss-momentum-scrolling', ['scroll', 'auto']], 'postcss-normalize', ...override.extraPostCSSPlugins].filter(Boolean)
97
82
  },
98
83
  sourceMap: isDev
99
84
  }
100
85
  }];
101
-
102
86
  if (preProcessor === 'less-loader') {
103
87
  loaders.push({
104
88
  loader: 'less-loader',
@@ -111,12 +95,10 @@ module.exports = function getWebpackConfig(args, override) {
111
95
  }
112
96
  });
113
97
  }
114
-
115
98
  return loaders;
116
99
  };
117
- /** @type {webpack.Configuration} */
118
-
119
100
 
101
+ /** @type {webpack.Configuration} */
120
102
  const config = {
121
103
  context: process.cwd(),
122
104
  mode: process.env.NODE_ENV,
@@ -151,7 +133,8 @@ module.exports = function getWebpackConfig(args, override) {
151
133
  }, qseCDN.isUseQsbSchemeRender && {
152
134
  '@qse/scheme-render': 'qsbSchemeRender',
153
135
  '@qsb/scheme-render': 'qsbSchemeRender'
154
- }), // 教育工程这些一定都需要 external
136
+ }),
137
+ // 教育工程这些一定都需要 external
155
138
  !appConfig.single && Object.assign({
156
139
  react: 'React',
157
140
  'react-dom': 'ReactDOM',
@@ -195,7 +178,8 @@ module.exports = function getWebpackConfig(args, override) {
195
178
  }
196
179
  },
197
180
  rules: [{
198
- oneOf: [// 两个 babel-loader 是为了处理 pdfjs-dist 与 ofd.js
181
+ oneOf: [
182
+ // 两个 babel-loader 是为了处理 pdfjs-dist 与 ofd.js
199
183
  {
200
184
  test: /\.(j|t)sx?$/,
201
185
  loader: 'babel-loader',
@@ -256,7 +240,6 @@ module.exports = function getWebpackConfig(args, override) {
256
240
  parser: {
257
241
  dataUrlCondition: {
258
242
  maxSize: imageInlineSizeLimit // 10kb
259
-
260
243
  }
261
244
  }
262
245
  }, {
@@ -265,9 +248,9 @@ module.exports = function getWebpackConfig(args, override) {
265
248
  parser: {
266
249
  dataUrlCondition: {
267
250
  maxSize: imageInlineSizeLimit // 10kb
268
-
269
251
  }
270
252
  },
253
+
271
254
  issuer: {
272
255
  and: [/\.(css|less)$/]
273
256
  }
@@ -345,7 +328,8 @@ module.exports = function getWebpackConfig(args, override) {
345
328
  keepNames: false,
346
329
  legalComments: 'none',
347
330
  target: 'es5'
348
- }), // This is only used in production mode
331
+ }),
332
+ // This is only used in production mode
349
333
  override.minify === 'terser' && new TerserPlugin({
350
334
  extractComments: false,
351
335
  terserOptions: {
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  const WebpackDevServer = require('webpack-dev-server');
4
+
4
5
  /**
5
6
  * @param {*} args
6
7
  * @param {import('../utils/defineConfig').Config} override
7
8
  */
8
-
9
-
10
9
  module.exports = function getWebpackDevServerConfig(args, override) {
11
10
  const host = process.env.HOST || '0.0.0.0';
12
11
  const sockHost = process.env.WDS_SOCKET_HOST;
13
12
  const sockPort = process.env.WDS_SOCKET_PORT;
14
- /** @type {WebpackDevServer.Configuration} */
15
13
 
14
+ /** @type {WebpackDevServer.Configuration} */
16
15
  const devServer = {
17
16
  hot: true,
18
17
  allowedHosts: 'all',