@yh-mf/preset 0.0.0-stage → 1.0.1
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/AGENTS.md +15 -0
- package/README.md +34 -2
- package/package.json +53 -4
- package/src/exposes/index.ts +12 -0
- package/src/index.ts +3 -0
- package/src/plugins/after-build-plugin.ts +55 -0
- package/src/plugins/clean-all-dist-plugin.ts +15 -0
- package/src/plugins/zip-after-build-plugin.ts +66 -0
- package/src/shared/index.ts +14 -0
- package/src/type/CreateMfHostOptions.ts +8 -0
- package/src/type/MfBaseShared.ts +1 -0
- package/src/type/MfRemoteOptions.ts +3 -0
- package/src/useMfRemoteDefineConfig/index.ts +181 -0
- package/tsconfig.json +24 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Commands
|
|
4
|
+
|
|
5
|
+
- `pnpm run build` - Build the library for production
|
|
6
|
+
- `pnpm run dev` - Turn on watch mode, watch for changes and rebuild the library
|
|
7
|
+
- `pnpm run test` - Run tests
|
|
8
|
+
- `pnpm run test:watch` - Run tests in watch mode
|
|
9
|
+
|
|
10
|
+
## Docs
|
|
11
|
+
|
|
12
|
+
- Rslib: https://rslib.rs/llms.txt
|
|
13
|
+
- Rsbuild: https://rsbuild.rs/llms.txt
|
|
14
|
+
- Rspack: https://rspack.rs/llms.txt
|
|
15
|
+
- Rstest: https://rstest.rs/llms.txt
|
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Rslib project
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install the dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Get started
|
|
12
|
+
|
|
13
|
+
Build the library:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm run build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Build the library in watch mode:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm run dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Run tests:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm run test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run tests in watch mode:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm run test:watch
|
|
35
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yh-mf/preset",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.ts",
|
|
10
|
+
"default": "./src/index.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"archiver": "^8.0.0",
|
|
19
|
+
"dayjs": "^1.11.23",
|
|
20
|
+
"globby": "^16.2.4",
|
|
21
|
+
"lodash-es": "^4.18.1",
|
|
22
|
+
"picocolors": "^1.1.1",
|
|
23
|
+
"unplugin-auto-import": "^21.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@module-federation/rsbuild-plugin": "2.8.1",
|
|
27
|
+
"@rsbuild/core": "^2.3.1",
|
|
28
|
+
"@rsbuild/plugin-babel": "^2.1.0",
|
|
29
|
+
"@rsbuild/plugin-sass": "^2.0.1",
|
|
30
|
+
"@rsbuild/plugin-vue": "^2.0.1",
|
|
31
|
+
"@rsbuild/plugin-vue-jsx": "^2.0.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@module-federation/rsbuild-plugin": "2.8.1",
|
|
35
|
+
"@rsbuild/core": "^2.3.1",
|
|
36
|
+
"@rsbuild/plugin-babel": "^2.1.0",
|
|
37
|
+
"@rsbuild/plugin-sass": "^2.0.1",
|
|
38
|
+
"@rsbuild/plugin-vue": "^2.0.1",
|
|
39
|
+
"@rsbuild/plugin-vue-jsx": "^2.0.1",
|
|
40
|
+
"@rslib/core": "^1.0.6",
|
|
41
|
+
"@rstest/adapter-rslib": "^0.12.5",
|
|
42
|
+
"@rstest/core": "^0.12.5",
|
|
43
|
+
"@types/archiver": "^8.0.0",
|
|
44
|
+
"@types/lodash-es": "^4.17.12",
|
|
45
|
+
"@types/node": "^26.6.6",
|
|
46
|
+
"archiver": "^8.0.0",
|
|
47
|
+
"dayjs": "^1.11.23",
|
|
48
|
+
"globby": "^16.2.4",
|
|
49
|
+
"lodash-es": "^4.18.1",
|
|
50
|
+
"picocolors": "^1.1.1",
|
|
51
|
+
"typescript": "^7.0.2",
|
|
52
|
+
"unplugin-auto-import": "^21.1.0",
|
|
53
|
+
"uuid": "^14.0.3"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const reg = /^.*src\/views\//g
|
|
2
|
+
const cwd = process.cwd();
|
|
3
|
+
import { globby } from "globby";
|
|
4
|
+
export const exposes = (await globby([`${cwd}/src/views/**/*.{vue,tsx,jsx}`, `!${cwd}/src/views/**/components/**/*`])).reduce(
|
|
5
|
+
(acc, curt) => {
|
|
6
|
+
const key = curt.replace(reg, "./").replace(/\.(vue|tsx|jsx)$/, "");
|
|
7
|
+
const value = curt.replace(reg, "./src/views/")
|
|
8
|
+
acc[key] = value;
|
|
9
|
+
return acc;
|
|
10
|
+
},
|
|
11
|
+
{} as Record<string, string>,
|
|
12
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type RsbuildPluginAPI } from "@rsbuild/core";
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export type Option = {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
description: string;
|
|
9
|
+
prefix: string;
|
|
10
|
+
mode: string | undefined;
|
|
11
|
+
parsed: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const afterBuildPlugin = (opt: Option) => ({
|
|
16
|
+
name: "after-build-plugin",
|
|
17
|
+
setup(api: RsbuildPluginAPI) {
|
|
18
|
+
api.onAfterBuild(async (params) => {
|
|
19
|
+
if (!params.stats?.hasErrors()) {
|
|
20
|
+
console.log('\n');
|
|
21
|
+
switch (opt.mode) {
|
|
22
|
+
case 'sit':
|
|
23
|
+
console.log("✅ sit环境构建结束");
|
|
24
|
+
console.log(pc.green(`🚀 预览地址:${opt.parsed.PUBLIC_MF_ENTRY}/${opt.name}/v${opt.version}`));
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
case 'prod':
|
|
28
|
+
console.log(pc.bgRed(`⚠️ 警告 如果菜单变动需要从sit环境同步到prod环境`))
|
|
29
|
+
console.log('\n');
|
|
30
|
+
console.log("✅ 生产构建结束!根据下面步骤进行部署至生产服务器并接入到微前端集群");
|
|
31
|
+
console.log(pc.green(`🚀 1、请将dist/v${opt.version}.${opt.prefix}.zip 上传至目标服务器中/www/his-platform-fe/${opt.name} 并解压`));
|
|
32
|
+
console.log(pc.red(`🚀 2、确认服务器中完整路径应该是 /www/his-platform-fe/${opt.name}/v${opt.version}.${opt.prefix}/index.html`));
|
|
33
|
+
console.log(pc.yellow(`🔗 3、进入预览地址确认您功能是否完整:${opt.parsed.PUBLIC_MF_ENTRY}/${opt.name}/v${opt.version} 注:如果是首次新增的模块是没有该项功能 请先完成步骤4`));
|
|
34
|
+
console.log(pc.blue(`👉 4、【首次新增模块】登录系统管理员账号;依次进入 系统管理-微前端管理[内]-微前端管理-点击新增按钮-弹窗填入:`));
|
|
35
|
+
console.log(pc.blue(` -4.1、应用名称[业务]: ${opt.description};`))
|
|
36
|
+
console.log(pc.blue(` -4.2、应用名称[系统]: ${opt.name};`))
|
|
37
|
+
console.log(pc.blue(` -4.3、应用类型:业务子应用;`))
|
|
38
|
+
console.log(pc.blue(` -4.4、模块入口:${opt.parsed.PUBLIC_MF_ENTRY}/${opt.name}`))
|
|
39
|
+
console.log(pc.blue(` -4.5、填写完成后保存`))
|
|
40
|
+
console.log(pc.blue(` -4.6、在微前端管理页面找到${opt.description}模块并点击当前版本旁边的‘+’ 进入版本发布页面`))
|
|
41
|
+
console.log(pc.blue(` -4.7、版本发布页面中点击新增版本`))
|
|
42
|
+
console.log(pc.blue(` -4.8、填入版本号:‘v${opt.version}.${opt.prefix}’和你的描述内容后保存`))
|
|
43
|
+
console.log(pc.blue(` -4.9、回到版本发布页面中发布你刚才的版本 到此你的子模块就正真的接入微前端集群`))
|
|
44
|
+
console.log(pc.magenta(`👉 5、【非首次新增模块】登录系统管理员账号;依次进入 系统管理-微前端管理[内]-微前端管理`));
|
|
45
|
+
console.log(pc.magenta(` -5.1、在微前端管理页面找到${opt.description}模块并点击当前版本 进入版本发布页面`))
|
|
46
|
+
console.log(pc.magenta(` -5.2、版本发布页面中点击新增版本`))
|
|
47
|
+
console.log(pc.magenta(` -5.3、填入版本号:‘v${opt.version}.${opt.prefix}’和你的描述内容后保存`))
|
|
48
|
+
console.log(pc.magenta(` -5.4、回到版本发布页面中发布你刚才的版本 到此你的子模块就正真的接入微前端集群`))
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
// 你的后置逻辑:复制文件、读取package.json、上传、版本脚本等
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RsbuildPluginAPI } from "@rsbuild/core";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export const cleanAllDistPlugin = () => ({
|
|
6
|
+
name: "after-build-plugin",
|
|
7
|
+
setup(api: RsbuildPluginAPI) {
|
|
8
|
+
api.onBeforeBuild(async () => {
|
|
9
|
+
const rootDist = path.resolve(process.cwd(), 'dist');
|
|
10
|
+
if (fs.existsSync(rootDist)) {
|
|
11
|
+
fs.rmSync(rootDist, { recursive: true, force: true });
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type RsbuildPluginAPI } from "@rsbuild/core";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { ZipArchive } from "archiver";
|
|
5
|
+
|
|
6
|
+
export type Option = {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
description: string;
|
|
10
|
+
prefix: string;
|
|
11
|
+
mode: string | undefined;
|
|
12
|
+
parsed: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const zipAfterBuildPlugin = (opt: Option) => ({
|
|
18
|
+
name: "zip-after-build-plugin",
|
|
19
|
+
setup(api: RsbuildPluginAPI) {
|
|
20
|
+
// 产物目录:dist/v1.0.1.11.13.11.32
|
|
21
|
+
const distRoot = path.resolve(
|
|
22
|
+
process.cwd(),
|
|
23
|
+
`dist/v${opt.version}.${opt.prefix}`,
|
|
24
|
+
);
|
|
25
|
+
// zip输出路径:dist/v1.0.1.11.13.11.32.zip
|
|
26
|
+
const zipOutPath = path.resolve(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
`dist/v${opt.version}.${opt.prefix}.zip`,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function zipFolder(sourceDir: string, zipPath: string): Promise<void> {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const output = fs.createWriteStream(zipPath);
|
|
35
|
+
const archive = new ZipArchive({
|
|
36
|
+
zlib: { level: 9 }, // Sets the compression level.
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
archive.pipe(output);
|
|
40
|
+
// false:压缩包内直接是文件,外面不套一层文件夹;填字符串则套一层
|
|
41
|
+
archive.directory(sourceDir, `v${opt.version}.${opt.prefix}`);
|
|
42
|
+
|
|
43
|
+
output.on("close", () => {
|
|
44
|
+
console.log(`✅ 压缩完成:${zipPath},大小:${archive.pointer()} bytes`);
|
|
45
|
+
resolve();
|
|
46
|
+
});
|
|
47
|
+
archive.on("error", (err: any) => reject(err));
|
|
48
|
+
archive.finalize();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
api.onAfterBuild(async (params) => {
|
|
53
|
+
// params.hasError 可以判断是否构建失败
|
|
54
|
+
|
|
55
|
+
if (opt.mode !== 'prod') return
|
|
56
|
+
if (!params.stats?.hasErrors()) {
|
|
57
|
+
console.log("📦 开始压缩目录:", distRoot);
|
|
58
|
+
try {
|
|
59
|
+
await zipFolder(distRoot, zipOutPath);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error("压缩失败:", err);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MfBaseShared } from "./../type/MfBaseShared";
|
|
2
|
+
|
|
3
|
+
export const baseShared: MfBaseShared = {
|
|
4
|
+
vue: { eager: true, singleton: true },
|
|
5
|
+
pinia: { eager: true, singleton: true },
|
|
6
|
+
"vue-router": { eager: true, singleton: true },
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function getShared(extra: Record<string, any> = {}) {
|
|
10
|
+
return {
|
|
11
|
+
...baseShared,
|
|
12
|
+
...extra,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface MfBaseShared extends Record<string, any>{}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { defineConfig, loadEnv, type RsbuildConfig } from "@rsbuild/core";
|
|
2
|
+
import { createModuleFederationConfig, pluginModuleFederation } from "@module-federation/rsbuild-plugin";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import AutoImport from "unplugin-auto-import/rspack";
|
|
6
|
+
import { pluginBabel } from "@rsbuild/plugin-babel";
|
|
7
|
+
import { pluginVueJsx } from "@rsbuild/plugin-vue-jsx";
|
|
8
|
+
import { pluginSass } from "@rsbuild/plugin-sass";
|
|
9
|
+
import { pluginVue } from "@rsbuild/plugin-vue";
|
|
10
|
+
import dayjs from "dayjs"
|
|
11
|
+
import { merge } from "lodash-es";
|
|
12
|
+
import pc from "picocolors";
|
|
13
|
+
|
|
14
|
+
import { afterBuildPlugin } from "./../plugins/after-build-plugin"
|
|
15
|
+
import { MfRemoteOptions } from "../type/MfRemoteOptions";
|
|
16
|
+
import { getShared } from "./../shared";
|
|
17
|
+
import { cleanAllDistPlugin } from "../plugins/clean-all-dist-plugin";
|
|
18
|
+
import { zipAfterBuildPlugin } from "../plugins/zip-after-build-plugin";
|
|
19
|
+
import { exposes } from "./../exposes"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export function useMfRemoteDefineConfig(mfRemoteOptions: MfRemoteOptions = {}) {
|
|
23
|
+
const cwd = process.cwd();
|
|
24
|
+
const prefix = dayjs().format("M.D.H.mm")
|
|
25
|
+
const { plugins: extraPlugins = [] } = mfRemoteOptions;
|
|
26
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
27
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
28
|
+
|
|
29
|
+
console.log("exposes", exposes);
|
|
30
|
+
|
|
31
|
+
return defineConfig(({ envMode: mode }): RsbuildConfig => {
|
|
32
|
+
const { parsed, publicVars } = loadEnv({
|
|
33
|
+
mode,
|
|
34
|
+
cwd,
|
|
35
|
+
prefixes: ["PUBLIC_"],
|
|
36
|
+
});
|
|
37
|
+
const hostName = `his-platform-fe`;
|
|
38
|
+
const platName = hostName.replace(/\-/g, "_");
|
|
39
|
+
const createMfConfig = createModuleFederationConfig({
|
|
40
|
+
name: platName,
|
|
41
|
+
remotes: {
|
|
42
|
+
[platName]: `${platName}@${parsed?.PUBLIC_MF_ENTRY}/${hostName}/mf-manifest.json`,
|
|
43
|
+
},
|
|
44
|
+
exposes,
|
|
45
|
+
dts: false,
|
|
46
|
+
shared: getShared(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
let output = {
|
|
51
|
+
cleanDistPath: true
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const { name, version, description } = pkg;
|
|
55
|
+
let assetPrefix, distPath = {}
|
|
56
|
+
switch (mode) {
|
|
57
|
+
case "sit":
|
|
58
|
+
assetPrefix = `${parsed?.PUBLIC_MF_ENTRY}/${name}/v${version}`;
|
|
59
|
+
distPath = {
|
|
60
|
+
root: `dist/${name}/v${version}`,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
console.log(pc.bold(pc.bgGreen(`👏 欢迎使用亚华HIS(MF)微前端集群 ✨`)));
|
|
64
|
+
console.log('\n');
|
|
65
|
+
console.log(pc.bold(pc.bgGreen(`正在构建中 请稍后!`)));
|
|
66
|
+
console.log('\n');
|
|
67
|
+
merge(output, { assetPrefix, distPath });
|
|
68
|
+
break;
|
|
69
|
+
case "prod":
|
|
70
|
+
|
|
71
|
+
assetPrefix = `${parsed?.PUBLIC_MF_ENTRY}/${name}/v${version}.${prefix}`;
|
|
72
|
+
distPath = {
|
|
73
|
+
root: `dist/v${version}.${prefix}`,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
console.log(pc.bold(pc.bgGreen(`👏 欢迎使用亚华HIS(MF)微前端集群 ✨`)));
|
|
77
|
+
console.log('\n');
|
|
78
|
+
console.log(pc.bold(pc.bgGreen(`正在构建中 请稍后!`)));
|
|
79
|
+
console.log('\n');
|
|
80
|
+
merge(output, { assetPrefix, distPath });
|
|
81
|
+
break;
|
|
82
|
+
case "dev":
|
|
83
|
+
assetPrefix = `/`;
|
|
84
|
+
console.log(
|
|
85
|
+
pc.bold(pc.bgGreen(`👏 欢迎使用亚华HIS(MF)微前端集群 ✨`)),
|
|
86
|
+
);
|
|
87
|
+
console.log("\n");
|
|
88
|
+
console.log(
|
|
89
|
+
pc.whiteBright(
|
|
90
|
+
`🧑💻 当前应用 ${description}(${hostName}) 版本 v${version} `,
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
console.log("\n");
|
|
94
|
+
console.log(`正在启动中 请稍后!`);
|
|
95
|
+
console.log("\n");
|
|
96
|
+
console.log(pc.yellow(`别问为什么这么写,当时它能跑,我就没敢动。`));
|
|
97
|
+
console.log(
|
|
98
|
+
pc.strikethrough(pc.yellow(`我不是没思路,我只是想刷会儿手机`)),
|
|
99
|
+
);
|
|
100
|
+
console.log(
|
|
101
|
+
pc.bold(pc.yellow(`联邦模块不打架,依赖不打架,今天就不脱发 🚀`)),
|
|
102
|
+
);
|
|
103
|
+
console.log(
|
|
104
|
+
pc.bold(pc.yellow(`状态同步难搞没关系,实在不行存 LocalStorage`)),
|
|
105
|
+
);
|
|
106
|
+
console.log(
|
|
107
|
+
pc.bold(pc.yellow(`架构设计天花乱坠,上线全靠 try-catch 兜底。`)),
|
|
108
|
+
);
|
|
109
|
+
console.log(pc.bold(pc.yellow(`头发珍贵,谨慎重构`)));
|
|
110
|
+
console.log(pc.bold(pc.yellow(`我不是没思路,我只是想刷会儿手机`)));
|
|
111
|
+
console.log(
|
|
112
|
+
pc.bold(pc.yellow(`Bug退散,构建随缘、头发珍贵,谨慎重构`)),
|
|
113
|
+
);
|
|
114
|
+
console.log(pc.bold(pc.yellow(`遇事不决,先清缓存`)));
|
|
115
|
+
console.log(pc.bold(pc.yellow(`调不通时,不妨摆烂十分钟`)));
|
|
116
|
+
console.log("\n");
|
|
117
|
+
console.log("\n");
|
|
118
|
+
merge(output, { assetPrefix });
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const plugins: any[] = [
|
|
125
|
+
afterBuildPlugin({ name, version, prefix , parsed, mode, description }),
|
|
126
|
+
zipAfterBuildPlugin({ name, version, prefix , parsed, mode, description }),
|
|
127
|
+
cleanAllDistPlugin(),
|
|
128
|
+
pluginBabel({
|
|
129
|
+
include: /\.(?:jsx|tsx)$/,
|
|
130
|
+
}),
|
|
131
|
+
pluginVue(),
|
|
132
|
+
pluginVueJsx(),
|
|
133
|
+
pluginSass(),
|
|
134
|
+
pluginModuleFederation(createMfConfig),
|
|
135
|
+
...(extraPlugins ?? []),
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
plugins,
|
|
140
|
+
output,
|
|
141
|
+
performance: {
|
|
142
|
+
removeConsole: true,
|
|
143
|
+
},
|
|
144
|
+
source: {
|
|
145
|
+
define: merge(parsed, publicVars, {
|
|
146
|
+
"process.env.PUBLIC_APP_NAME": JSON.stringify(name),
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
resolve: {
|
|
150
|
+
alias: {
|
|
151
|
+
"@": path.resolve(cwd, "./src"),
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
server: {
|
|
155
|
+
cors: {
|
|
156
|
+
origin: "*",
|
|
157
|
+
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
|
|
158
|
+
allowedHeaders: "*",
|
|
159
|
+
maxAge: 86400,
|
|
160
|
+
credentials: false,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
tools: {
|
|
164
|
+
rspack: {
|
|
165
|
+
plugins: [
|
|
166
|
+
AutoImport({
|
|
167
|
+
imports: ["vue", "vue-router", "pinia"],
|
|
168
|
+
dirs: ["src/composables"],
|
|
169
|
+
dts: "./src/auto-imports.d.ts",
|
|
170
|
+
vueTemplate: true,
|
|
171
|
+
}),
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
} as RsbuildConfig;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["ES2022"],
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"noEmit": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"types": ["node"],
|
|
9
|
+
"useDefineForClassFields": true,
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
|
|
12
|
+
/* modules */
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"allowImportingTsExtensions": true,
|
|
18
|
+
|
|
19
|
+
/* type checking */
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*", "types/**/*"]
|
|
24
|
+
}
|