@autobest-ui/scripts 1.9.1-alpha.2 → 1.9.1-alpha.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/bin/spa.js +0 -0
- package/bin/ssr.js +0 -0
- package/common/start.js +1 -1
- package/common/utils.js +28 -12
- package/common/webpack.common.js +12 -0
- package/package.json +2 -2
- package/spaConfig/webpack.dev.js +0 -9
- package/ssrConfig/webpack.dev.client.js +1 -12
- package/ssrConfig/webpack.dev.js +0 -9
- package/ssrConfig/webpack.dev.server.js +1 -12
- package/ssrConfig/webpack.prod.client.js +2 -4
package/bin/spa.js
CHANGED
|
File without changes
|
package/bin/ssr.js
CHANGED
|
File without changes
|
package/common/start.js
CHANGED
|
@@ -45,7 +45,7 @@ function openStartRun(webpackFactory) {
|
|
|
45
45
|
try {
|
|
46
46
|
const config = extendWebpackConfigFromProject(
|
|
47
47
|
webpackFactory,
|
|
48
|
-
{ ...appConfig, port: PORT
|
|
48
|
+
{ ...appConfig, startOpenPath, ...parseArgsToJson, port: PORT },
|
|
49
49
|
extendEnv,
|
|
50
50
|
{ isProd: false, isServer: false, isHotServer: false }
|
|
51
51
|
);
|
package/common/utils.js
CHANGED
|
@@ -4,6 +4,8 @@ const fs = require('fs');
|
|
|
4
4
|
// 执行node命令时候的文件绝对路径
|
|
5
5
|
const root = process.cwd();
|
|
6
6
|
|
|
7
|
+
const argsReg = /^--[0-9a-zA-Z]+$/;
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* 从根目录开始获取文件绝对地址路径
|
|
9
11
|
* @param filePath 文件参数
|
|
@@ -15,21 +17,35 @@ function getProjectPath(...filePath) {
|
|
|
15
17
|
|
|
16
18
|
function getParseArgsToJson() {
|
|
17
19
|
const args = process.argv.slice(2);
|
|
18
|
-
const length = args.length - 1;
|
|
19
20
|
const result = {};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
throw Error('Run args error, example: --port 3030');
|
|
24
|
-
}
|
|
25
|
-
const key = args[count].substring(2);
|
|
26
|
-
count++;
|
|
27
|
-
if (count > length) {
|
|
28
|
-
result[key] = '';
|
|
21
|
+
const length = args.length;
|
|
22
|
+
for (let count = 0; count < args.length; count++) {
|
|
23
|
+
if (!length || count >= length) {
|
|
29
24
|
break;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
if (!argsReg.test(args[0])) {
|
|
27
|
+
throw Error('Run args error, example: "--port 3030" or "--eslint"');
|
|
28
|
+
}
|
|
29
|
+
const currentItem = args[count];
|
|
30
|
+
if (argsReg.test(currentItem)) {
|
|
31
|
+
const key = currentItem.substring(2);
|
|
32
|
+
if (count + 1 >= length) {
|
|
33
|
+
result[key] = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
const nextItem = args[count + 1];
|
|
37
|
+
if (argsReg.test(nextItem)) {
|
|
38
|
+
result[key] = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
result[key] = isNaN(Number(nextItem))
|
|
42
|
+
? nextItem === 'false'
|
|
43
|
+
? false
|
|
44
|
+
: nextItem === 'true'
|
|
45
|
+
? true
|
|
46
|
+
: nextItem
|
|
47
|
+
: Number(nextItem);
|
|
48
|
+
}
|
|
33
49
|
}
|
|
34
50
|
return result;
|
|
35
51
|
}
|
package/common/webpack.common.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const webpack = require('webpack');
|
|
2
|
+
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
2
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
4
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|
4
5
|
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
@@ -231,6 +232,17 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
|
|
|
231
232
|
})
|
|
232
233
|
);
|
|
233
234
|
}
|
|
235
|
+
if (!isProd && appConfig.eslint) {
|
|
236
|
+
result.plugins.push(
|
|
237
|
+
new ESLintPlugin({
|
|
238
|
+
exclude: 'node_modules',
|
|
239
|
+
threads: 4,
|
|
240
|
+
failOnError: false,
|
|
241
|
+
lintDirtyModulesOnly: false,
|
|
242
|
+
extensions: ['tsx', 'ts', 'js']
|
|
243
|
+
})
|
|
244
|
+
);
|
|
245
|
+
}
|
|
234
246
|
|
|
235
247
|
if (isProd && !isServer) {
|
|
236
248
|
result.optimization = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobest-ui/scripts",
|
|
3
|
-
"version": "1.9.1-alpha.
|
|
3
|
+
"version": "1.9.1-alpha.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "utils for project tools",
|
|
6
6
|
"bin": {
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"eslint": "^8.23.1",
|
|
103
103
|
"typescript": "4.8.3"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "abd91e39442fa57d018e1ec3bb82135280c37041"
|
|
106
106
|
}
|
package/spaConfig/webpack.dev.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { merge } = require('webpack-merge');
|
|
2
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
3
2
|
const ip = require('ip');
|
|
4
3
|
const FriendlyErrorsPlugin = require('@soda/friendly-errors-webpack-plugin');
|
|
5
4
|
const { getProjectPath } = require('../common/utils');
|
|
@@ -18,14 +17,6 @@ module.exports = function (appConfig, extendEnv) {
|
|
|
18
17
|
chunkFilename: '[name].chunk.js'
|
|
19
18
|
},
|
|
20
19
|
plugins: [
|
|
21
|
-
// eslint只在本地开发时检测
|
|
22
|
-
new ESLintPlugin({
|
|
23
|
-
exclude: 'node_modules',
|
|
24
|
-
threads: 4,
|
|
25
|
-
failOnError: false,
|
|
26
|
-
lintDirtyModulesOnly: false,
|
|
27
|
-
extensions: ['tsx', 'ts', 'js']
|
|
28
|
-
}),
|
|
29
20
|
// 相关配置文档:https://github.com/geowarin/friendly-errors-webpack-plugin
|
|
30
21
|
new FriendlyErrorsPlugin({
|
|
31
22
|
compilationSuccessInfo: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { merge } = require('webpack-merge');
|
|
2
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
3
2
|
const LoadablePlugin = require('@loadable/webpack-plugin');
|
|
4
3
|
const { getProjectPath } = require('../common/utils');
|
|
5
4
|
const baseConfig = require('./webpack.base');
|
|
@@ -27,17 +26,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
|
|
|
27
26
|
filename: `${appConfig.baseStaticJsPath}/[name].js`,
|
|
28
27
|
chunkFilename: `${appConfig.baseStaticJsPath}/[name].js`
|
|
29
28
|
},
|
|
30
|
-
plugins: [
|
|
31
|
-
// eslint只在本地开发时检测
|
|
32
|
-
new ESLintPlugin({
|
|
33
|
-
exclude: 'node_modules',
|
|
34
|
-
threads: 4,
|
|
35
|
-
failOnError: false,
|
|
36
|
-
lintDirtyModulesOnly: isProd,
|
|
37
|
-
extensions: ['tsx', 'ts', 'js']
|
|
38
|
-
}),
|
|
39
|
-
new LoadablePlugin()
|
|
40
|
-
]
|
|
29
|
+
plugins: [new LoadablePlugin()]
|
|
41
30
|
}
|
|
42
31
|
);
|
|
43
32
|
};
|
package/ssrConfig/webpack.dev.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { merge } = require('webpack-merge');
|
|
2
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
3
2
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
3
|
const ip = require('ip');
|
|
5
4
|
const FriendlyErrorsPlugin = require('@soda/friendly-errors-webpack-plugin');
|
|
@@ -25,14 +24,6 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
|
|
|
25
24
|
chunkFilename: '[name].chunk.js'
|
|
26
25
|
},
|
|
27
26
|
plugins: [
|
|
28
|
-
// eslint只在本地开发时检测
|
|
29
|
-
new ESLintPlugin({
|
|
30
|
-
exclude: 'node_modules',
|
|
31
|
-
threads: 4,
|
|
32
|
-
failOnError: false,
|
|
33
|
-
lintDirtyModulesOnly: isProd,
|
|
34
|
-
extensions: ['tsx', 'ts', 'js']
|
|
35
|
-
}),
|
|
36
27
|
// 相关配置文档:https://github.com/geowarin/friendly-errors-webpack-plugin
|
|
37
28
|
new FriendlyErrorsPlugin({
|
|
38
29
|
compilationSuccessInfo: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const webpack = require('webpack');
|
|
2
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
3
2
|
const nodeExternals = require('webpack-node-externals');
|
|
4
3
|
const { merge } = require('webpack-merge');
|
|
5
4
|
const { getProjectPath } = require('../common/utils');
|
|
@@ -47,17 +46,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
|
|
|
47
46
|
]
|
|
48
47
|
},
|
|
49
48
|
// 覆盖查找规则, 减少无用模块
|
|
50
|
-
plugins: [
|
|
51
|
-
// eslint只在本地开发时检测
|
|
52
|
-
new ESLintPlugin({
|
|
53
|
-
exclude: 'node_modules',
|
|
54
|
-
threads: 4,
|
|
55
|
-
failOnError: false,
|
|
56
|
-
lintDirtyModulesOnly: isProd,
|
|
57
|
-
extensions: ['tsx', 'ts', 'js']
|
|
58
|
-
}),
|
|
59
|
-
new webpack.ContextReplacementPlugin(/any-promise/)
|
|
60
|
-
],
|
|
49
|
+
plugins: [new webpack.ContextReplacementPlugin(/any-promise/)],
|
|
61
50
|
// 避免路径丢失
|
|
62
51
|
node: {
|
|
63
52
|
__filename: true,
|
|
@@ -78,10 +78,8 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
|
|
|
78
78
|
},
|
|
79
79
|
vendor: {
|
|
80
80
|
test: /[\\/]node_modules[\\/]/,
|
|
81
|
-
chunks: '
|
|
82
|
-
name: 'vendor'
|
|
83
|
-
minChunks: 1,
|
|
84
|
-
priority: 10
|
|
81
|
+
chunks: 'all',
|
|
82
|
+
name: 'vendor'
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
},
|