@qse/edu-scripts 1.14.5 → 1.14.7
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 +9 -0
- package/README.md +3 -3
- package/docs/deploy.md +1 -0
- package/lib/asset/template/edu-app-env.d.ts.tpl +5 -0
- package/lib/cli.js +5 -0
- package/lib/config/webpackConfig.js +11 -1
- package/lib/config/webpackDevServerConfig.js +28 -5
- package/lib/deploy.js +9 -0
- package/lib/utils/defineConfig.d.ts +19 -2
- package/package.json +37 -37
- package/src/asset/template/edu-app-env.d.ts.tpl +5 -0
- package/src/cli.js +6 -0
- package/src/config/webpackConfig.js +23 -10
- package/src/config/webpackDevServerConfig.js +31 -5
- package/src/deploy.js +9 -0
- package/src/utils/defineConfig.ts +20 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ nodejs 版本至少 12+
|
|
|
14
14
|
|
|
15
15
|
```shell
|
|
16
16
|
# npm 安装
|
|
17
|
-
npm create @qse/edu-app
|
|
17
|
+
npm create @qse/edu-app@latest
|
|
18
18
|
|
|
19
19
|
# 或者 yarn 安装
|
|
20
|
-
yarn create @qse/edu-app
|
|
20
|
+
yarn create @qse/edu-app@latest
|
|
21
21
|
|
|
22
22
|
# 或者 pnpm 安装
|
|
23
|
-
pnpm create @qse/edu-app
|
|
23
|
+
pnpm create @qse/edu-app@latest
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## 安装
|
package/docs/deploy.md
CHANGED
package/lib/cli.js
CHANGED
|
@@ -32,6 +32,11 @@ require("yargs").usage(`教育工程化 webpack5 基础框架
|
|
|
32
32
|
desc: "上传到公文",
|
|
33
33
|
default: false,
|
|
34
34
|
boolean: true
|
|
35
|
+
}).option("compositionshelves", {
|
|
36
|
+
alias: "c",
|
|
37
|
+
desc: "上传到文曲智阅",
|
|
38
|
+
default: false,
|
|
39
|
+
boolean: true
|
|
35
40
|
}),
|
|
36
41
|
(args) => require("./deploy")(args)
|
|
37
42
|
).command(
|
|
@@ -11,6 +11,7 @@ var appPkg = require(paths.package);
|
|
|
11
11
|
var appConfig = require("../utils/appConfig");
|
|
12
12
|
var { ESBuildMinifyPlugin } = require("esbuild-loader");
|
|
13
13
|
var ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
14
|
+
var once = require("lodash/once");
|
|
14
15
|
var jsMainPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.name}` : `${appPkg.name}/${appPkg.name}`;
|
|
15
16
|
var assetPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.version}` : `${appPkg.name}/${appPkg.version}`;
|
|
16
17
|
var cssRegex = /\.css$/;
|
|
@@ -352,7 +353,16 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
352
353
|
}
|
|
353
354
|
})
|
|
354
355
|
) : [],
|
|
355
|
-
process.env.ANALYZE && isProd && new BundleAnalyzerPlugin()
|
|
356
|
+
process.env.ANALYZE && isProd && new BundleAnalyzerPlugin(),
|
|
357
|
+
isDev && !!override.startup && ((compiler) => {
|
|
358
|
+
compiler.hooks.afterDone.tap(
|
|
359
|
+
"edu-scripts-startup",
|
|
360
|
+
once(() => {
|
|
361
|
+
const logger = compiler.getInfrastructureLogger("edu-scripts");
|
|
362
|
+
override.startup({ logger, chalk: require("chalk"), compiler });
|
|
363
|
+
})
|
|
364
|
+
);
|
|
365
|
+
})
|
|
356
366
|
].filter(Boolean),
|
|
357
367
|
optimization: {
|
|
358
368
|
minimize: isProd && override.minify !== false,
|
|
@@ -32,18 +32,41 @@ module.exports = function getWebpackDevServerConfig(args, override) {
|
|
|
32
32
|
return middlewares;
|
|
33
33
|
},
|
|
34
34
|
proxy: [
|
|
35
|
-
...override.proxy,
|
|
36
35
|
{
|
|
37
36
|
context: ["/api"],
|
|
38
37
|
target: "http://192.168.10.19:3339/qsxxwapdev",
|
|
39
38
|
changeOrigin: true,
|
|
40
|
-
headers: {
|
|
41
|
-
host: "www.zhidianbao.cn",
|
|
42
|
-
origin: "http://www.zhidianbao.cn"
|
|
43
|
-
}
|
|
39
|
+
headers: { host: "www.zhidianbao.cn", origin: "http://www.zhidianbao.cn" }
|
|
44
40
|
}
|
|
45
41
|
],
|
|
46
42
|
compress: true
|
|
47
43
|
};
|
|
44
|
+
if (override.proxy) {
|
|
45
|
+
if (Array.isArray(override.proxy)) {
|
|
46
|
+
devServer.proxy = [...override.proxy, ...devServer.proxy];
|
|
47
|
+
} else if (typeof override.proxy === "object") {
|
|
48
|
+
const proxies = Object.entries(override.proxy).map(([context, target]) => {
|
|
49
|
+
const url = new URL(target);
|
|
50
|
+
return {
|
|
51
|
+
context: [context],
|
|
52
|
+
target,
|
|
53
|
+
changeOrigin: true,
|
|
54
|
+
headers: { host: url.host, origin: url.origin }
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
devServer.proxy = [...proxies, ...devServer.proxy];
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error("proxy 必须是数组或对象");
|
|
60
|
+
}
|
|
61
|
+
const proxyMap = /* @__PURE__ */ new Map();
|
|
62
|
+
devServer.proxy = devServer.proxy.filter((item) => {
|
|
63
|
+
const key = JSON.stringify([...item.context].sort());
|
|
64
|
+
if (!proxyMap.has(key)) {
|
|
65
|
+
proxyMap.set(key, true);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
48
71
|
return devServer;
|
|
49
72
|
};
|
package/lib/deploy.js
CHANGED
|
@@ -29,6 +29,10 @@ async function normalDeploy(args) {
|
|
|
29
29
|
d: {
|
|
30
30
|
context: "eduwebngv1",
|
|
31
31
|
folder: "documentshelves"
|
|
32
|
+
},
|
|
33
|
+
c: {
|
|
34
|
+
context: "eduwebngv1",
|
|
35
|
+
folder: "compositionshelves"
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments);
|
|
@@ -104,6 +108,9 @@ async function normalDeploy(args) {
|
|
|
104
108
|
if (args.d) {
|
|
105
109
|
presets.push(presetConfig.d);
|
|
106
110
|
}
|
|
111
|
+
if (args.c) {
|
|
112
|
+
presets.push(presetConfig.c);
|
|
113
|
+
}
|
|
107
114
|
if (presets.length === 0) {
|
|
108
115
|
console.log(
|
|
109
116
|
`
|
|
@@ -115,6 +122,8 @@ async function normalDeploy(args) {
|
|
|
115
122
|
${chalk.green("edu-scripts deploy -b")}
|
|
116
123
|
# 部署代码 公文
|
|
117
124
|
${chalk.green("edu-scripts deploy -d")}
|
|
125
|
+
# 部署代码 文曲智阅
|
|
126
|
+
${chalk.green("edu-scripts deploy -c")}
|
|
118
127
|
# 部署代码 校端 + 局端
|
|
119
128
|
${chalk.green("edu-scripts deploy -s -b")}
|
|
120
129
|
`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Chalk } from 'chalk';
|
|
2
|
+
import type { Compiler, Configuration } from 'webpack';
|
|
2
3
|
import type { Configuration as DevServerConfiguration, ProxyConfigArray } from 'webpack-dev-server';
|
|
3
4
|
export type BabelImportPlugin = [
|
|
4
5
|
'import',
|
|
@@ -55,9 +56,14 @@ export type Config = {
|
|
|
55
56
|
define?: Record<string, any>;
|
|
56
57
|
/**
|
|
57
58
|
* webpack-dev-server proxy
|
|
59
|
+
*
|
|
60
|
+
* context 填写的顺序很重要,前面的会优先匹配。可以重复定义 /api 来覆盖默认的配置
|
|
61
|
+
* @see https://webpack.js.org/configuration/dev-server/#devserverproxy
|
|
58
62
|
* @default /api -> /qsxxwapdev/api
|
|
63
|
+
* @example { '/api': 'http://localhost:3000' }
|
|
64
|
+
* @example [{ context: ['/api'], target: 'http://localhost:3000' }]
|
|
59
65
|
*/
|
|
60
|
-
proxy?: ProxyConfigArray
|
|
66
|
+
proxy?: ProxyConfigArray | Record<string, string>;
|
|
61
67
|
extraPostCSSPlugins?: any[];
|
|
62
68
|
/**
|
|
63
69
|
* 开启 mock 功能,会自动加载 mock 文件夹下的文件
|
|
@@ -66,5 +72,16 @@ export type Config = {
|
|
|
66
72
|
* 如果设置 false,会关闭 mock 功能
|
|
67
73
|
*/
|
|
68
74
|
mock?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* 开发模式启动后只执行一次的函数,用来展示启动后的提示信息,或者自定义的逻辑
|
|
77
|
+
*/
|
|
78
|
+
startup?: (params: {
|
|
79
|
+
/** 控制台输出内容 */
|
|
80
|
+
logger: ReturnType<Compiler['getInfrastructureLogger']>;
|
|
81
|
+
/** 字体颜色相关工具 */
|
|
82
|
+
chalk: Chalk;
|
|
83
|
+
/** webpack compiler 自定义的时候会用到 */
|
|
84
|
+
compiler: Compiler;
|
|
85
|
+
}) => void;
|
|
69
86
|
};
|
|
70
87
|
export declare function defineConfig(config: Config): Config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qse/edu-scripts",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.7",
|
|
4
4
|
"author": "Kinoko",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "教育工程化基础框架",
|
|
@@ -34,74 +34,74 @@
|
|
|
34
34
|
"extends": "qsb-react"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@babel/core": "~7.
|
|
38
|
-
"@babel/plugin-proposal-decorators": "~7.
|
|
39
|
-
"@babel/plugin-transform-runtime": "~7.
|
|
40
|
-
"@babel/preset-env": "~7.
|
|
41
|
-
"@babel/preset-react": "~7.
|
|
42
|
-
"@babel/preset-typescript": "~7.
|
|
43
|
-
"@babel/register": "~7.
|
|
44
|
-
"@babel/runtime": "~7.
|
|
45
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
37
|
+
"@babel/core": "~7.24.7",
|
|
38
|
+
"@babel/plugin-proposal-decorators": "~7.24.7",
|
|
39
|
+
"@babel/plugin-transform-runtime": "~7.24.7",
|
|
40
|
+
"@babel/preset-env": "~7.24.7",
|
|
41
|
+
"@babel/preset-react": "~7.24.7",
|
|
42
|
+
"@babel/preset-typescript": "~7.24.7",
|
|
43
|
+
"@babel/register": "~7.24.6",
|
|
44
|
+
"@babel/runtime": "~7.24.7",
|
|
45
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
46
46
|
"@qse/ssh-sftp": "^1.0.1",
|
|
47
|
-
"@svgr/webpack": "^8.0
|
|
47
|
+
"@svgr/webpack": "^8.1.0",
|
|
48
48
|
"babel-loader": "^9.1.3",
|
|
49
49
|
"babel-plugin-import": "^1.13.8",
|
|
50
50
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
51
51
|
"chalk": "^4.1.2",
|
|
52
|
-
"chokidar": "^3.
|
|
52
|
+
"chokidar": "^3.6.0",
|
|
53
53
|
"cookie-parser": "^1.4.6",
|
|
54
|
-
"css-loader": "^6.
|
|
55
|
-
"cssnano": "^6.
|
|
56
|
-
"debug": "^4.3.
|
|
54
|
+
"css-loader": "^6.11.0",
|
|
55
|
+
"cssnano": "^6.1.2",
|
|
56
|
+
"debug": "^4.3.5",
|
|
57
57
|
"esbuild-loader": "^2.21.0",
|
|
58
|
-
"express": "^4.
|
|
58
|
+
"express": "^4.19.2",
|
|
59
59
|
"filesize": "^8.0.7",
|
|
60
60
|
"fs-extra": "^10.1.0",
|
|
61
61
|
"globby": "^11.1.0",
|
|
62
62
|
"gzip-size": "^6.0.0",
|
|
63
|
-
"html-webpack-plugin": "^5.
|
|
64
|
-
"image-minimizer-webpack-plugin": "^3.
|
|
65
|
-
"inquirer": "^8.2.
|
|
63
|
+
"html-webpack-plugin": "^5.6.0",
|
|
64
|
+
"image-minimizer-webpack-plugin": "^3.8.3",
|
|
65
|
+
"inquirer": "^8.2.6",
|
|
66
66
|
"less": "^3.13.1",
|
|
67
67
|
"less-loader": "^10.2.0",
|
|
68
68
|
"lodash": "^4.17.21",
|
|
69
69
|
"multer": "^1.4.5-lts.1",
|
|
70
70
|
"open": "^8.4.2",
|
|
71
|
-
"path-to-regexp": "^6.2.
|
|
72
|
-
"postcss": "^8.4.
|
|
71
|
+
"path-to-regexp": "^6.2.2",
|
|
72
|
+
"postcss": "^8.4.38",
|
|
73
73
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
74
|
-
"postcss-loader": "^7.3.
|
|
74
|
+
"postcss-loader": "^7.3.4",
|
|
75
75
|
"postcss-momentum-scrolling": "^3.14.22",
|
|
76
76
|
"postcss-normalize": "^8.0.1",
|
|
77
|
-
"postcss-preset-env": "^9.
|
|
77
|
+
"postcss-preset-env": "^9.5.14",
|
|
78
78
|
"prettier": "^2.8.8",
|
|
79
79
|
"prettier-plugin-tailwindcss": "^0.4.1",
|
|
80
|
-
"react-refresh": "^0.14.
|
|
80
|
+
"react-refresh": "^0.14.2",
|
|
81
81
|
"recursive-readdir": "^2.2.3",
|
|
82
82
|
"rimraf": "^3.0.2",
|
|
83
|
-
"semver": "^7.
|
|
84
|
-
"sharp": "^0.32.
|
|
83
|
+
"semver": "^7.6.2",
|
|
84
|
+
"sharp": "^0.32.6",
|
|
85
85
|
"strip-ansi": "^6.0.1",
|
|
86
|
-
"style-loader": "^3.3.
|
|
87
|
-
"tailwindcss": "^3.
|
|
88
|
-
"terser-webpack-plugin": "~5.3.
|
|
89
|
-
"tmp": "^0.2.
|
|
90
|
-
"typescript": "^5.
|
|
86
|
+
"style-loader": "^3.3.4",
|
|
87
|
+
"tailwindcss": "^3.4.4",
|
|
88
|
+
"terser-webpack-plugin": "~5.3.10",
|
|
89
|
+
"tmp": "^0.2.3",
|
|
90
|
+
"typescript": "^5.4.5",
|
|
91
91
|
"update-notifier": "^5.1.0",
|
|
92
92
|
"url-loader": "^4.1.1",
|
|
93
|
-
"webpack": "^5.
|
|
94
|
-
"webpack-bundle-analyzer": "^4.
|
|
95
|
-
"webpack-dev-server": "^4.15.
|
|
93
|
+
"webpack": "^5.92.0",
|
|
94
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
95
|
+
"webpack-dev-server": "^4.15.2",
|
|
96
96
|
"yargs": "^17.7.2"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@types/fs-extra": "^9.0.13",
|
|
100
100
|
"@types/jest": "^28.1.8",
|
|
101
|
-
"@types/yargs": "^17.0.
|
|
102
|
-
"dumi": "^1.1.
|
|
101
|
+
"@types/yargs": "^17.0.32",
|
|
102
|
+
"dumi": "^1.1.54",
|
|
103
103
|
"eslint-config-qsb-react": "^1.1.1",
|
|
104
|
-
"father": "^4.
|
|
104
|
+
"father": "^4.4.4",
|
|
105
105
|
"jest": "^28.1.3"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/src/cli.js
CHANGED
|
@@ -9,7 +9,8 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
|
|
|
9
9
|
const appPkg = require(paths.package)
|
|
10
10
|
const appConfig = require('../utils/appConfig')
|
|
11
11
|
const { ESBuildMinifyPlugin } = require('esbuild-loader')
|
|
12
|
-
const ImageMinimizerPlugin = require(
|
|
12
|
+
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin')
|
|
13
|
+
const once = require('lodash/once')
|
|
13
14
|
|
|
14
15
|
const jsMainPath = appConfig.grayscale
|
|
15
16
|
? `${appPkg.name}/beta/${appPkg.name}`
|
|
@@ -378,21 +379,33 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
378
379
|
)
|
|
379
380
|
: []),
|
|
380
381
|
process.env.ANALYZE && isProd && new BundleAnalyzerPlugin(),
|
|
382
|
+
isDev &&
|
|
383
|
+
!!override.startup &&
|
|
384
|
+
((compiler) => {
|
|
385
|
+
compiler.hooks.afterDone.tap(
|
|
386
|
+
'edu-scripts-startup',
|
|
387
|
+
once(() => {
|
|
388
|
+
const logger = compiler.getInfrastructureLogger('edu-scripts')
|
|
389
|
+
override.startup({ logger, chalk: require('chalk'), compiler })
|
|
390
|
+
})
|
|
391
|
+
)
|
|
392
|
+
}),
|
|
381
393
|
].filter(Boolean),
|
|
382
394
|
optimization: {
|
|
383
395
|
minimize: isProd && override.minify !== false,
|
|
384
396
|
minimizer: [
|
|
385
|
-
override.minifyImage &&
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
397
|
+
override.minifyImage &&
|
|
398
|
+
new ImageMinimizerPlugin({
|
|
399
|
+
minimizer: {
|
|
400
|
+
implementation: ImageMinimizerPlugin.sharpMinify,
|
|
401
|
+
options: {
|
|
402
|
+
encodeOptions: {
|
|
403
|
+
// Your options for `sharp`
|
|
404
|
+
// https://sharp.pixelplumbing.com/api-output
|
|
405
|
+
},
|
|
392
406
|
},
|
|
393
407
|
},
|
|
394
|
-
},
|
|
395
|
-
}),
|
|
408
|
+
}),
|
|
396
409
|
override.minify === 'esbuild' &&
|
|
397
410
|
new ESBuildMinifyPlugin({
|
|
398
411
|
pure: override.pure_funcs ?? ['console.log'],
|
|
@@ -39,19 +39,45 @@ module.exports = function getWebpackDevServerConfig(args, override) {
|
|
|
39
39
|
return middlewares
|
|
40
40
|
},
|
|
41
41
|
proxy: [
|
|
42
|
-
...override.proxy,
|
|
43
42
|
{
|
|
44
43
|
context: ['/api'],
|
|
45
44
|
target: 'http://192.168.10.19:3339/qsxxwapdev',
|
|
46
45
|
changeOrigin: true,
|
|
47
|
-
headers: {
|
|
48
|
-
host: 'www.zhidianbao.cn',
|
|
49
|
-
origin: 'http://www.zhidianbao.cn',
|
|
50
|
-
},
|
|
46
|
+
headers: { host: 'www.zhidianbao.cn', origin: 'http://www.zhidianbao.cn' },
|
|
51
47
|
},
|
|
52
48
|
],
|
|
53
49
|
compress: true,
|
|
54
50
|
}
|
|
55
51
|
|
|
52
|
+
if (override.proxy) {
|
|
53
|
+
if (Array.isArray(override.proxy)) {
|
|
54
|
+
devServer.proxy = [...override.proxy, ...devServer.proxy]
|
|
55
|
+
} else if (typeof override.proxy === 'object') {
|
|
56
|
+
const proxies = Object.entries(override.proxy).map(([context, target]) => {
|
|
57
|
+
const url = new URL(target)
|
|
58
|
+
return {
|
|
59
|
+
context: [context],
|
|
60
|
+
target: target,
|
|
61
|
+
changeOrigin: true,
|
|
62
|
+
headers: { host: url.host, origin: url.origin },
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
devServer.proxy = [...proxies, ...devServer.proxy]
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error('proxy 必须是数组或对象')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 清理重复的代理配置
|
|
71
|
+
const proxyMap = new Map()
|
|
72
|
+
devServer.proxy = devServer.proxy.filter((item) => {
|
|
73
|
+
const key = JSON.stringify([...item.context].sort())
|
|
74
|
+
if (!proxyMap.has(key)) {
|
|
75
|
+
proxyMap.set(key, true)
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
return false
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
56
82
|
return devServer
|
|
57
83
|
}
|
package/src/deploy.js
CHANGED
|
@@ -31,6 +31,10 @@ async function normalDeploy(args) {
|
|
|
31
31
|
context: 'eduwebngv1',
|
|
32
32
|
folder: 'documentshelves',
|
|
33
33
|
},
|
|
34
|
+
c: {
|
|
35
|
+
context: 'eduwebngv1',
|
|
36
|
+
folder: 'compositionshelves',
|
|
37
|
+
},
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments)
|
|
@@ -134,6 +138,9 @@ async function normalDeploy(args) {
|
|
|
134
138
|
if (args.d) {
|
|
135
139
|
presets.push(presetConfig.d)
|
|
136
140
|
}
|
|
141
|
+
if (args.c) {
|
|
142
|
+
presets.push(presetConfig.c)
|
|
143
|
+
}
|
|
137
144
|
if (presets.length === 0) {
|
|
138
145
|
console.log(
|
|
139
146
|
`
|
|
@@ -145,6 +152,8 @@ async function normalDeploy(args) {
|
|
|
145
152
|
${chalk.green('edu-scripts deploy -b')}
|
|
146
153
|
# 部署代码 公文
|
|
147
154
|
${chalk.green('edu-scripts deploy -d')}
|
|
155
|
+
# 部署代码 文曲智阅
|
|
156
|
+
${chalk.green('edu-scripts deploy -c')}
|
|
148
157
|
# 部署代码 校端 + 局端
|
|
149
158
|
${chalk.green('edu-scripts deploy -s -b')}
|
|
150
159
|
`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Chalk } from 'chalk'
|
|
2
|
+
import type { Compiler, Configuration } from 'webpack'
|
|
2
3
|
import type { Configuration as DevServerConfiguration, ProxyConfigArray } from 'webpack-dev-server'
|
|
3
4
|
|
|
4
5
|
export type BabelImportPlugin = [
|
|
@@ -52,14 +53,19 @@ export type Config = {
|
|
|
52
53
|
* 打包时压缩图片资源
|
|
53
54
|
* @default true
|
|
54
55
|
*/
|
|
55
|
-
minifyImage?:boolean
|
|
56
|
+
minifyImage?: boolean
|
|
56
57
|
/** 自定义全局参数 */
|
|
57
58
|
define?: Record<string, any>
|
|
58
59
|
/**
|
|
59
60
|
* webpack-dev-server proxy
|
|
61
|
+
*
|
|
62
|
+
* context 填写的顺序很重要,前面的会优先匹配。可以重复定义 /api 来覆盖默认的配置
|
|
63
|
+
* @see https://webpack.js.org/configuration/dev-server/#devserverproxy
|
|
60
64
|
* @default /api -> /qsxxwapdev/api
|
|
65
|
+
* @example { '/api': 'http://localhost:3000' }
|
|
66
|
+
* @example [{ context: ['/api'], target: 'http://localhost:3000' }]
|
|
61
67
|
*/
|
|
62
|
-
proxy?: ProxyConfigArray
|
|
68
|
+
proxy?: ProxyConfigArray | Record<string, string>
|
|
63
69
|
extraPostCSSPlugins?: any[]
|
|
64
70
|
/**
|
|
65
71
|
* 开启 mock 功能,会自动加载 mock 文件夹下的文件
|
|
@@ -68,6 +74,17 @@ export type Config = {
|
|
|
68
74
|
* 如果设置 false,会关闭 mock 功能
|
|
69
75
|
*/
|
|
70
76
|
mock?: boolean
|
|
77
|
+
/**
|
|
78
|
+
* 开发模式启动后只执行一次的函数,用来展示启动后的提示信息,或者自定义的逻辑
|
|
79
|
+
*/
|
|
80
|
+
startup?: (params: {
|
|
81
|
+
/** 控制台输出内容 */
|
|
82
|
+
logger: ReturnType<Compiler['getInfrastructureLogger']>
|
|
83
|
+
/** 字体颜色相关工具 */
|
|
84
|
+
chalk: Chalk
|
|
85
|
+
/** webpack compiler 自定义的时候会用到 */
|
|
86
|
+
compiler: Compiler
|
|
87
|
+
}) => void
|
|
71
88
|
}
|
|
72
89
|
export function defineConfig(config: Config) {
|
|
73
90
|
return config
|