@autobest-ui/scripts 1.0.2 → 1.0.5
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/README.md +1 -1
- package/common/appConfig.js +16 -0
- package/common/webpack.common.js +22 -4
- package/package.json +3 -2
- package/ssrConfig/webpack.base.js +2 -2
- package/ssrConfig/webpack.dev.client.js +0 -1
- package/ssrConfig/webpack.dev.js +0 -1
- package/ssrConfig/webpack.dev.server.js +3 -1
- package/ssrConfig/webpack.prod.client.js +0 -3
- package/ssrConfig/webpack.prod.server.js +0 -3
package/README.md
CHANGED
package/common/appConfig.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const { getProjectPath } = require('./utils');
|
|
2
3
|
|
|
4
|
+
let pkgInfo = {
|
|
5
|
+
name: 'ui',
|
|
6
|
+
version: '1.0.0'
|
|
7
|
+
};
|
|
8
|
+
try {
|
|
9
|
+
const pkgPath = getProjectPath('/package.json');
|
|
10
|
+
const pkgStr = fs.readFileSync(pkgPath);
|
|
11
|
+
pkgInfo = JSON.parse(pkgStr);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.warn('The current project does not have a package.json file or content error!!!');
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
const configPath = getProjectPath('/config/app.config.js');
|
|
4
18
|
|
|
5
19
|
const config = require(configPath);
|
|
6
20
|
|
|
7
21
|
module.exports = {
|
|
22
|
+
projectName: pkgInfo.name,
|
|
23
|
+
projectVersion: pkgInfo.version,
|
|
8
24
|
startDefaultPort: 3030,
|
|
9
25
|
startEntry: '/src/index.tsx',
|
|
10
26
|
...config
|
package/common/webpack.common.js
CHANGED
|
@@ -77,7 +77,7 @@ function getStyleLoaders({ isProd, isServer, isHotServer, isSass, moduleOption =
|
|
|
77
77
|
return result;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer
|
|
80
|
+
module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
|
|
81
81
|
const result = {
|
|
82
82
|
stats: 'errors-only',
|
|
83
83
|
// 原始源代码(仅限行)定位到原始代码问题,比source-map 快,但是没有列映射(column mapping)的 source-map
|
|
@@ -88,6 +88,17 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
|
|
|
88
88
|
output: {
|
|
89
89
|
publicPath: '/'
|
|
90
90
|
},
|
|
91
|
+
cache: {
|
|
92
|
+
type: 'filesystem',
|
|
93
|
+
version: `${appConfig.projectName}_${isProd ? '1' : '0'}${isServer ? '1' : '0'}${isHotServer ? '1' : '0'}_${
|
|
94
|
+
appConfig.projectVersion
|
|
95
|
+
}`,
|
|
96
|
+
store: 'pack',
|
|
97
|
+
buildDependencies: {
|
|
98
|
+
defaultWebpack: ['webpack/lib/'],
|
|
99
|
+
config: [__filename]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
91
102
|
// 配置各种loader
|
|
92
103
|
module: {
|
|
93
104
|
// 警告替换为Error
|
|
@@ -97,7 +108,15 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
|
|
|
97
108
|
oneOf: [
|
|
98
109
|
{
|
|
99
110
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
100
|
-
type: 'asset'
|
|
111
|
+
type: 'asset',
|
|
112
|
+
parser: {
|
|
113
|
+
dataUrlCondition: {
|
|
114
|
+
maxSize: 2048
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
generator: {
|
|
118
|
+
filename: `static/[name].[contenthash:8].[ext]?v=${extendEnv.version}`
|
|
119
|
+
}
|
|
101
120
|
},
|
|
102
121
|
{
|
|
103
122
|
test: /\.(js|ts|tsx)$/,
|
|
@@ -225,8 +244,7 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer, isSetCo
|
|
|
225
244
|
const extendResult = extendConfig(result, appConfig, extendEnv, {
|
|
226
245
|
isProd,
|
|
227
246
|
isServer,
|
|
228
|
-
isHotServer
|
|
229
|
-
isSetCommonAlias
|
|
247
|
+
isHotServer
|
|
230
248
|
});
|
|
231
249
|
if (!extendResult) {
|
|
232
250
|
throw Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobest-ui/scripts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "utils for project tools",
|
|
6
6
|
"bin": {
|
|
@@ -86,10 +86,11 @@
|
|
|
86
86
|
"sass-loader": "12.6.0",
|
|
87
87
|
"style-loader": "3.3.1",
|
|
88
88
|
"terser-webpack-plugin": "5.3.1",
|
|
89
|
+
"ts-node": "9.1.1",
|
|
89
90
|
"webpack": "5.70.0",
|
|
90
91
|
"webpack-dev-server": "4.7.4",
|
|
91
92
|
"webpack-merge": "5.8.0",
|
|
92
93
|
"webpack-node-externals": "3.0.0"
|
|
93
94
|
},
|
|
94
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "3cb84df7169090f2cea8e54ded7f537f4ce4decf"
|
|
95
96
|
}
|
|
@@ -2,7 +2,7 @@ const { merge } = require('webpack-merge');
|
|
|
2
2
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
3
|
const webpackCommon = require('../common/webpack.common');
|
|
4
4
|
|
|
5
|
-
module.exports = (appConfig, extendEnv, { isServer, isHotServer,
|
|
5
|
+
module.exports = (appConfig, extendEnv, { isServer, isHotServer, isProd }) => {
|
|
6
6
|
const result = {
|
|
7
7
|
plugins: [],
|
|
8
8
|
module: {
|
|
@@ -19,5 +19,5 @@ module.exports = (appConfig, extendEnv, { isServer, isHotServer, isSetCommonAlia
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer, isHotServer
|
|
22
|
+
return merge(webpackCommon(appConfig, extendEnv, { isProd, isServer, isHotServer }), result);
|
|
23
23
|
};
|
package/ssrConfig/webpack.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const webpack = require('webpack');
|
|
1
2
|
const nodeExternals = require('webpack-node-externals');
|
|
2
3
|
const { merge } = require('webpack-merge');
|
|
3
4
|
const { getProjectPath } = require('../common/utils');
|
|
@@ -8,7 +9,6 @@ module.exports = function (appConfig, extendEnv) {
|
|
|
8
9
|
baseConfig(appConfig, extendEnv, {
|
|
9
10
|
isServer: true,
|
|
10
11
|
isHotServer: true,
|
|
11
|
-
isSetCommonAlias: true,
|
|
12
12
|
isProd: false
|
|
13
13
|
}),
|
|
14
14
|
{
|
|
@@ -45,6 +45,8 @@ module.exports = function (appConfig, extendEnv) {
|
|
|
45
45
|
}
|
|
46
46
|
]
|
|
47
47
|
},
|
|
48
|
+
// 覆盖查找规则, 减少无用模块
|
|
49
|
+
plugins: [new webpack.ContextReplacementPlugin(/any-promise/)],
|
|
48
50
|
// 避免路径丢失
|
|
49
51
|
node: {
|
|
50
52
|
__filename: true,
|
|
@@ -5,14 +5,11 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
|
5
5
|
const { getProjectPath } = require('../common/utils');
|
|
6
6
|
const baseConfig = require('./webpack.base');
|
|
7
7
|
|
|
8
|
-
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
9
|
-
|
|
10
8
|
module.exports = function (appConfig, extendEnv) {
|
|
11
9
|
return merge(
|
|
12
10
|
baseConfig(appConfig, extendEnv, {
|
|
13
11
|
isServer: false,
|
|
14
12
|
isHotServer: false,
|
|
15
|
-
isSetCommonAlias: isCommonBuild,
|
|
16
13
|
isProd: true
|
|
17
14
|
}),
|
|
18
15
|
{
|
|
@@ -3,14 +3,11 @@ const { merge } = require('webpack-merge');
|
|
|
3
3
|
const { getProjectPath } = require('../common/utils');
|
|
4
4
|
const baseConfig = require('./webpack.base');
|
|
5
5
|
|
|
6
|
-
const isCommonBuild = process.env.REACT_APP_BUILD_TYPE === 'common';
|
|
7
|
-
|
|
8
6
|
module.exports = function (appConfig, extendEnv) {
|
|
9
7
|
return merge(
|
|
10
8
|
baseConfig(appConfig, extendEnv, {
|
|
11
9
|
isServer: true,
|
|
12
10
|
isHotServer: false,
|
|
13
|
-
isSetCommonAlias: isCommonBuild,
|
|
14
11
|
isProd: true
|
|
15
12
|
}),
|
|
16
13
|
{
|