@qse/edu-scripts 1.12.3 → 1.12.4

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,9 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.12.4 (2022-11-03)
4
+
5
+ - feat: 优化 cdn external 规则
6
+
3
7
  ## 1.12.3 (2022-11-01)
4
8
 
5
9
  - fix: 修复 commit-dist 错误
package/docs/override.md CHANGED
@@ -59,8 +59,8 @@ const path = require('path')
59
59
 
60
60
  module.exports = defineConfig({
61
61
  alias: {
62
- config: path.resolve(__dirname,'src/config')
63
- }
62
+ config: path.resolve(__dirname, 'src/config'),
63
+ },
64
64
  })
65
65
  ```
66
66
 
@@ -70,7 +70,7 @@ module.exports = defineConfig({
70
70
  const { defineConfig } = require('@qse/edu-scripts')
71
71
 
72
72
  module.exports = defineConfig({
73
- pure_funcs: []
73
+ pure_funcs: [],
74
74
  })
75
75
  ```
76
76
 
@@ -98,7 +98,7 @@ module.exports = defineConfig({
98
98
 
99
99
  适用范围:antd-mobile@2, antd-mobile@5
100
100
 
101
- 安装公司内专用的 pxtorem 插件,比原版增加了 include 与 CSS变量 编译。并且修改默认值 `1rem === 10px`
101
+ 安装公司内专用的 pxtorem 插件,比原版增加了 include 与 CSS 变量 编译。并且修改默认值 `1rem === 10px`
102
102
 
103
103
  ```bash
104
104
  npm i @qse/postcss-pxtorem
@@ -106,14 +106,10 @@ npm i @qse/postcss-pxtorem
106
106
 
107
107
  ```js
108
108
  const { defineConfig } = require('@qse/edu-scripts')
109
- const pxtorem = require('@qse/postcss-pxtorem')
109
+ const pxtorem = require('@qse/postcss-pxtorem')
110
110
 
111
111
  module.exports = defineConfig({
112
- extraPostCSSPlugins: [
113
- pxtorem({
114
- include: ['antd-mobile']
115
- })
116
- ]
112
+ extraPostCSSPlugins: [pxtorem({ include: ['antd-mobile'] })],
117
113
  })
118
114
  ```
119
115
 
@@ -137,8 +133,7 @@ module.exports = defineConfig({
137
133
  var maxFontSize = max / scale
138
134
  }
139
135
 
140
- docEl.style.fontSize =
141
- Math.min((docEl.clientWidth / designWidth) * base, maxFontSize) + 'px'
136
+ docEl.style.fontSize = Math.min((docEl.clientWidth / designWidth) * base, maxFontSize) + 'px'
142
137
  }
143
138
  resize()
144
139
  window.addEventListener('resize', resize)
@@ -154,12 +149,32 @@ module.exports = defineConfig({
154
149
  const { defineConfig } = require('@qse/edu-scripts')
155
150
 
156
151
  module.exports = defineConfig({
157
- babel(config){
158
- config.plugins.push([
159
- 'import',
160
- { libraryName: 'antd-mobile', libraryDirectory: 'es', style: true },
161
- 'antd-mobile',
162
- ])
163
- }
152
+ babel(config) {
153
+ config.plugins.push(['import', { libraryName: 'antd-mobile', style: true }, 'antd-mobile'])
154
+ },
155
+ })
156
+ ```
157
+
158
+ ### 兼容 antd-mobile@1
159
+
160
+ 安装 `svg-sprite-loader` 模块,复制下面的代码
161
+
162
+ ```shell
163
+ npm i svg-sprite-loader
164
+ ```
165
+
166
+ ```js
167
+ const { defineConfig } = require('@qse/edu-scripts')
168
+ module.exports = defineConfig({
169
+ webpack(config) {
170
+ config.module.rules[0].oneOf.unshift({
171
+ test: /\.svg$/,
172
+ loader: 'svg-sprite-loader',
173
+ options: {
174
+ esModule: false,
175
+ runtimeCompat: true,
176
+ },
177
+ })
178
+ },
164
179
  })
165
180
  ```
@@ -36,21 +36,19 @@ const imageInlineSizeLimit = 10 * 1024;
36
36
 
37
37
  const qsbCDN = (() => {
38
38
  const contents = paths.indexHTML.map(url => fs.readFileSync(url, 'utf-8'));
39
- const isUseCommon = contents.some(content => /react16.14.*_common31?.js/.test(content));
40
- const isUseAxios = contents.some(content => /react16.14.*_axios0.21.1/.test(content));
41
- const isUseMoment = contents.some(content => content.includes('moment2.29.1.js'));
42
- const isUseAntd = contents.some(content => content.includes('antd3.26.20.js'));
43
- const isUseQsbAntd = contents.some(content => content.includes('qsb-antd.min.js'));
44
- const isUseQsbSchemeRender = contents.some(content => content.includes('qsb-scheme-render.min.js'));
45
- const isUse = isUseAntd || isUseCommon || isUseMoment || isUseAxios || isUseQsbAntd || isUseQsbSchemeRender;
39
+
40
+ function include(pattern) {
41
+ const regexp = new RegExp(pattern);
42
+ return contents.some(content => regexp.test(content));
43
+ }
44
+
46
45
  return {
47
- isUse,
48
- isUseAntd,
49
- isUseCommon,
50
- isUseMoment,
51
- isUseAxios,
52
- isUseQsbAntd,
53
- isUseQsbSchemeRender
46
+ isUseCommon: include(/react16.14.*_common31?.js|react-dev-preset.js/),
47
+ isUseAxios: include(/react16.14.*_axios0.21.1|react-dev-preset.js/),
48
+ isUseMoment: include('moment2.29.1.js'),
49
+ isUseAntd: include('antd3.26.20.js'),
50
+ isUseQsbAntd: include('qsb-antd.min.js'),
51
+ isUseQsbSchemeRender: include('qsb-scheme-render.min.js')
54
52
  };
55
53
  })();
56
54
  /**
@@ -136,7 +134,8 @@ module.exports = function getWebpackConfig(args, override) {
136
134
  'react-dom': 'ReactDOM',
137
135
  'natty-fetch': 'nattyFetch',
138
136
  'natty-storage': 'nattyStorage',
139
- 'common-utils': 'CommonUtils'
137
+ 'common-utils': 'CommonUtils',
138
+ '@qse/common-utils': 'CommonUtils'
140
139
  }, qsbCDN.isUseAxios && {
141
140
  axios: 'axios'
142
141
  }, qsbCDN.isUseMoment && {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qse/edu-scripts",
3
- "version": "1.12.3",
3
+ "version": "1.12.4",
4
4
  "author": "Kinoko",
5
5
  "license": "MIT",
6
6
  "description": "教育工程化基础框架",
@@ -26,25 +26,19 @@ const imageInlineSizeLimit = 10 * 1024
26
26
 
27
27
  const qsbCDN = (() => {
28
28
  const contents = paths.indexHTML.map((url) => fs.readFileSync(url, 'utf-8'))
29
- const isUseCommon = contents.some((content) => /react16.14.*_common31?.js/.test(content))
30
- const isUseAxios = contents.some((content) => /react16.14.*_axios0.21.1/.test(content))
31
- const isUseMoment = contents.some((content) => content.includes('moment2.29.1.js'))
32
- const isUseAntd = contents.some((content) => content.includes('antd3.26.20.js'))
33
- const isUseQsbAntd = contents.some((content) => content.includes('qsb-antd.min.js'))
34
- const isUseQsbSchemeRender = contents.some((content) =>
35
- content.includes('qsb-scheme-render.min.js')
36
- )
37
29
 
38
- const isUse =
39
- isUseAntd || isUseCommon || isUseMoment || isUseAxios || isUseQsbAntd || isUseQsbSchemeRender
30
+ function include(pattern) {
31
+ const regexp = new RegExp(pattern)
32
+ return contents.some((content) => regexp.test(content))
33
+ }
34
+
40
35
  return {
41
- isUse,
42
- isUseAntd,
43
- isUseCommon,
44
- isUseMoment,
45
- isUseAxios,
46
- isUseQsbAntd,
47
- isUseQsbSchemeRender,
36
+ isUseCommon: include(/react16.14.*_common31?.js|react-dev-preset.js/),
37
+ isUseAxios: include(/react16.14.*_axios0.21.1|react-dev-preset.js/),
38
+ isUseMoment: include('moment2.29.1.js'),
39
+ isUseAntd: include('antd3.26.20.js'),
40
+ isUseQsbAntd: include('qsb-antd.min.js'),
41
+ isUseQsbSchemeRender: include('qsb-scheme-render.min.js'),
48
42
  }
49
43
  })()
50
44
 
@@ -139,6 +133,7 @@ module.exports = function getWebpackConfig(args, override) {
139
133
  'natty-fetch': 'nattyFetch',
140
134
  'natty-storage': 'nattyStorage',
141
135
  'common-utils': 'CommonUtils',
136
+ '@qse/common-utils': 'CommonUtils',
142
137
  },
143
138
  qsbCDN.isUseAxios && { axios: 'axios' },
144
139
  qsbCDN.isUseMoment && { moment: 'moment' },