@qse/edu-scripts 1.12.2 → 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 +8 -0
- package/docs/override.md +34 -19
- package/lib/build.js +0 -4
- package/lib/commit-dist.js +8 -12
- package/lib/config/webpackConfig.js +14 -16
- package/package.json +1 -1
- package/src/build.js +0 -4
- package/src/commit-dist.js +4 -5
- package/src/config/webpackConfig.js +12 -18
package/CHANGELOG.md
CHANGED
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
```
|
package/lib/build.js
CHANGED
package/lib/commit-dist.js
CHANGED
|
@@ -14,8 +14,6 @@ const exec = (cmd, opts) => require('child_process').execSync(cmd, {
|
|
|
14
14
|
|
|
15
15
|
const tmp = require('tmp');
|
|
16
16
|
|
|
17
|
-
const glob = require('globby');
|
|
18
|
-
|
|
19
17
|
function validateSVNRoot(root) {
|
|
20
18
|
const ls = exec(`svn ls ${root}`);
|
|
21
19
|
return ['trunk', 'branches'].every(s => ls.includes(s));
|
|
@@ -67,17 +65,15 @@ function copyDistToRepo(info) {
|
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
exec(`svn co ${info.distBranchDirURL} ${tmpdir}`);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
exec(`svn rm * --force -q`, {
|
|
71
|
+
cwd: tmpdir
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {}
|
|
74
|
+
|
|
76
75
|
fs.copySync(paths.dist, tmpdir);
|
|
77
|
-
|
|
78
|
-
cwd: tmpdir
|
|
79
|
-
});
|
|
80
|
-
exec(`svn add "${files.join('" "')}"`, {
|
|
76
|
+
exec(`svn add * --force --auto-props --parents --depth infinity -q`, {
|
|
81
77
|
cwd: tmpdir
|
|
82
78
|
});
|
|
83
79
|
const msg = `[edu-scripts] commit ${info.branch} dist #${info.revision} @${info.author}`;
|
|
@@ -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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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 && {
|
|
@@ -275,7 +274,6 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
275
274
|
}, {
|
|
276
275
|
loader: 'url-loader',
|
|
277
276
|
options: {
|
|
278
|
-
name: `images/${assetPath}/[name].[hash:6].[ext]`,
|
|
279
277
|
limit: imageInlineSizeLimit
|
|
280
278
|
}
|
|
281
279
|
}],
|
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -44,10 +44,6 @@ module.exports = async function build(args) {
|
|
|
44
44
|
if (stats.compilation.errors.length) {
|
|
45
45
|
console.log(chalk.red('编译失败'))
|
|
46
46
|
console.log(stats.toString({ all: false, errors: true, colors: true }))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Fail the build if running in a CI server
|
|
50
|
-
if (error || stats.compilation.errors.length) {
|
|
51
47
|
process.exit(1)
|
|
52
48
|
}
|
|
53
49
|
|
package/src/commit-dist.js
CHANGED
|
@@ -4,7 +4,6 @@ const fs = require('fs-extra')
|
|
|
4
4
|
const exec = (cmd, opts) =>
|
|
5
5
|
require('child_process').execSync(cmd, { encoding: 'utf-8', stdio: 'pipe', ...opts })
|
|
6
6
|
const tmp = require('tmp')
|
|
7
|
-
const glob = require('globby')
|
|
8
7
|
|
|
9
8
|
function validateSVNRoot(root) {
|
|
10
9
|
const ls = exec(`svn ls ${root}`)
|
|
@@ -49,13 +48,13 @@ function copyDistToRepo(info) {
|
|
|
49
48
|
}
|
|
50
49
|
exec(`svn co ${info.distBranchDirURL} ${tmpdir}`)
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
try {
|
|
52
|
+
exec(`svn rm * --force -q`, { cwd: tmpdir })
|
|
53
|
+
} catch (error) {}
|
|
54
54
|
|
|
55
55
|
fs.copySync(paths.dist, tmpdir)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
exec(`svn add "${files.join('" "')}"`, { cwd: tmpdir })
|
|
57
|
+
exec(`svn add * --force --auto-props --parents --depth infinity -q`, { cwd: tmpdir })
|
|
59
58
|
|
|
60
59
|
const msg = `[edu-scripts] commit ${info.branch} dist #${info.revision} @${info.author}`
|
|
61
60
|
exec(`svn ci -m "${msg}"`, { cwd: tmpdir })
|
|
@@ -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
|
-
|
|
39
|
-
|
|
30
|
+
function include(pattern) {
|
|
31
|
+
const regexp = new RegExp(pattern)
|
|
32
|
+
return contents.some((content) => regexp.test(content))
|
|
33
|
+
}
|
|
34
|
+
|
|
40
35
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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' },
|
|
@@ -290,7 +285,6 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
290
285
|
{
|
|
291
286
|
loader: 'url-loader',
|
|
292
287
|
options: {
|
|
293
|
-
name: `images/${assetPath}/[name].[hash:6].[ext]`,
|
|
294
288
|
limit: imageInlineSizeLimit,
|
|
295
289
|
},
|
|
296
290
|
},
|