@4399ywkf/cli 1.0.6 → 1.0.8
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/dist/templates/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/Locale.tsx +14 -18
- package/dist/templates/MainContentWrap.tsx +11 -15
- package/dist/templates/ThemeContext.tsx +27 -24
- package/dist/templates/actions.ts +14 -11
- package/dist/templates/app/config/env/.env.public.tpl +2 -19
- package/dist/templates/app/config/jwt/index.ts +4 -4
- package/dist/templates/app/config/request/error-handler.ts +67 -0
- package/dist/templates/app/config/request/index.ts +127 -129
- package/dist/templates/app/config/request/interceptors.ts +118 -0
- package/dist/templates/app/config/request/token-manager.ts +23 -0
- package/dist/templates/app/config/request/types.ts +63 -0
- package/dist/templates/app/config/rspack/rspack.config.mjs +62 -61
- package/dist/templates/app/config/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/app/locales/zh-CN/common.json +3 -0
- package/dist/templates/app/package.json.tpl +1 -10
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/app/react-app-env.d.ts +13 -8
- package/dist/templates/app/src/bootstrap/index.ts +34 -0
- package/dist/templates/app/src/config/env.ts +84 -0
- package/dist/templates/app/src/index.tsx +17 -54
- package/dist/templates/app/src/layout/Locale.tsx +14 -18
- package/dist/templates/app/src/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/app/src/layout/ThemeContext.tsx +27 -24
- package/dist/templates/app/src/locales/default/common.ts +3 -1
- package/dist/templates/app/src/micro/garfish.ts +53 -0
- package/dist/templates/app/src/pages/base/index.tsx +189 -25
- package/dist/templates/app/src/routes.tsx +21 -12
- package/dist/templates/app/src/types/global.d.ts +19 -0
- package/dist/templates/app/src/utils/index.ts +3 -1
- package/dist/templates/app/store/middleware/createDevtools.ts +7 -7
- package/dist/templates/base/index.tsx +189 -25
- package/dist/templates/bootstrap/index.ts +34 -0
- package/dist/templates/common.json +3 -0
- package/dist/templates/common.ts +3 -1
- package/dist/templates/config/env/.env.public.tpl +2 -19
- package/dist/templates/config/env.ts +84 -0
- package/dist/templates/config/jwt/index.ts +4 -4
- package/dist/templates/config/request/error-handler.ts +67 -0
- package/dist/templates/config/request/index.ts +127 -129
- package/dist/templates/config/request/interceptors.ts +118 -0
- package/dist/templates/config/request/token-manager.ts +23 -0
- package/dist/templates/config/request/types.ts +63 -0
- package/dist/templates/config/rspack/rspack.config.mjs +62 -61
- package/dist/templates/config/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/createDevtools.ts +7 -7
- package/dist/templates/default/common.ts +3 -1
- package/dist/templates/env/.env.public.tpl +2 -19
- package/dist/templates/env.ts +83 -2
- package/dist/templates/error-handler.ts +67 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/garfish.ts +53 -0
- package/dist/templates/global.d.ts +19 -0
- package/dist/templates/index.tsx +189 -25
- package/dist/templates/initialState.ts +28 -10
- package/dist/templates/interceptors.ts +118 -0
- package/dist/templates/jwt/index.ts +4 -4
- package/dist/templates/layout/Locale.tsx +14 -18
- package/dist/templates/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/layout/ThemeContext.tsx +27 -24
- package/dist/templates/locales/default/common.ts +3 -1
- package/dist/templates/locales/zh-CN/common.json +3 -0
- package/dist/templates/micro/garfish.ts +53 -0
- package/dist/templates/middleware/createDevtools.ts +7 -7
- package/dist/templates/package.json.tpl +1 -10
- package/dist/templates/page.tsx +21 -19
- package/dist/templates/pages/base/index.tsx +189 -25
- package/dist/templates/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/react-app-env.d.ts +13 -8
- package/dist/templates/request/error-handler.ts +67 -0
- package/dist/templates/request/index.ts +127 -129
- package/dist/templates/request/interceptors.ts +118 -0
- package/dist/templates/request/token-manager.ts +23 -0
- package/dist/templates/request/types.ts +63 -0
- package/dist/templates/routes.tsx +21 -12
- package/dist/templates/rspack/rspack.config.mjs +62 -61
- package/dist/templates/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/rspack.config.mjs +62 -61
- package/dist/templates/rspack.prod.mjs +41 -62
- package/dist/templates/src/bootstrap/index.ts +34 -0
- package/dist/templates/src/config/env.ts +84 -0
- package/dist/templates/src/index.tsx +17 -54
- package/dist/templates/src/layout/Locale.tsx +14 -18
- package/dist/templates/src/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/src/layout/ThemeContext.tsx +27 -24
- package/dist/templates/src/locales/default/common.ts +3 -1
- package/dist/templates/src/micro/garfish.ts +53 -0
- package/dist/templates/src/pages/base/index.tsx +189 -25
- package/dist/templates/src/routes.tsx +21 -12
- package/dist/templates/src/types/global.d.ts +19 -0
- package/dist/templates/src/utils/index.ts +3 -1
- package/dist/templates/store/middleware/createDevtools.ts +7 -7
- package/dist/templates/token-manager.ts +23 -0
- package/dist/templates/types/global.d.ts +19 -0
- package/dist/templates/utils/index.ts +3 -1
- package/dist/templates/zh-CN/common.json +3 -0
- package/package.json +1 -1
- package/dist/templates/app/config/sentry/sentry.config.ts +0 -188
- package/dist/templates/app/src/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/app/src/hooks/useSentry.ts +0 -92
- package/dist/templates/app/src/pages/base/layout.tsx +0 -6
- package/dist/templates/app/src/pages/base/page.tsx +0 -25
- package/dist/templates/app/src/utils/env.ts +0 -3
- package/dist/templates/app/src/utils/format.ts +0 -21
- package/dist/templates/app/src/utils/getMicroApp.ts +0 -39
- package/dist/templates/app/src/utils/sentry.ts +0 -187
- package/dist/templates/app/src/utils/sentryDecorators.ts +0 -34
- package/dist/templates/app/src/utils/updateVersion.ts +0 -186
- package/dist/templates/base/layout.tsx +0 -6
- package/dist/templates/base/page.tsx +0 -25
- package/dist/templates/config/public/404.png +0 -0
- package/dist/templates/config/public/favicon.ico +0 -0
- package/dist/templates/config/public/images/banner_market_modal.webp +0 -0
- package/dist/templates/config/public/images/chatmode_chat_dark.webp +0 -0
- package/dist/templates/config/public/images/chatmode_chat_light.webp +0 -0
- package/dist/templates/config/public/images/chatmode_docs_dark.webp +0 -0
- package/dist/templates/config/public/images/chatmode_docs_light.webp +0 -0
- package/dist/templates/config/public/images/empty_topic_dark.webp +0 -0
- package/dist/templates/config/public/images/empty_topic_light.webp +0 -0
- package/dist/templates/config/public/images/screenshot_background.webp +0 -0
- package/dist/templates/config/public/images/theme_auto.webp +0 -0
- package/dist/templates/config/public/images/theme_dark.webp +0 -0
- package/dist/templates/config/public/images/theme_light.webp +0 -0
- package/dist/templates/config/public/index.html +0 -29
- package/dist/templates/config/sentry/sentry.config.ts +0 -188
- package/dist/templates/format.ts +0 -21
- package/dist/templates/getMicroApp.ts +0 -39
- package/dist/templates/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/hooks/useSentry.ts +0 -92
- package/dist/templates/layout.tsx +0 -6
- package/dist/templates/pages/base/layout.tsx +0 -6
- package/dist/templates/pages/base/page.tsx +0 -25
- package/dist/templates/sentry/sentry.config.ts +0 -188
- package/dist/templates/sentry.config.ts +0 -188
- package/dist/templates/sentry.ts +0 -187
- package/dist/templates/sentryDecorators.ts +0 -34
- package/dist/templates/src/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/src/hooks/useSentry.ts +0 -92
- package/dist/templates/src/pages/base/layout.tsx +0 -6
- package/dist/templates/src/pages/base/page.tsx +0 -25
- package/dist/templates/src/utils/env.ts +0 -3
- package/dist/templates/src/utils/format.ts +0 -21
- package/dist/templates/src/utils/getMicroApp.ts +0 -39
- package/dist/templates/src/utils/sentry.ts +0 -187
- package/dist/templates/src/utils/sentryDecorators.ts +0 -34
- package/dist/templates/src/utils/updateVersion.ts +0 -186
- package/dist/templates/updateVersion.ts +0 -186
- package/dist/templates/useRouteTitle.tsx +0 -36
- package/dist/templates/useSentry.ts +0 -92
- package/dist/templates/utils/env.ts +0 -3
- package/dist/templates/utils/format.ts +0 -21
- package/dist/templates/utils/getMicroApp.ts +0 -39
- package/dist/templates/utils/sentry.ts +0 -187
- package/dist/templates/utils/sentryDecorators.ts +0 -34
- package/dist/templates/utils/updateVersion.ts +0 -186
- /package/dist/templates/app/{config/public → public}/404.png +0 -0
- /package/dist/templates/app/{config/public → public}/favicon.ico +0 -0
- /package/dist/templates/app/{config/public → public}/images/banner_market_modal.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_chat_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_chat_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_docs_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_docs_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/empty_topic_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/empty_topic_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/screenshot_background.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_auto.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/index.html +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
2
|
-
import { rspack } from
|
|
3
|
-
import path from
|
|
4
|
-
import fs from
|
|
5
|
-
import { RsdoctorRspackPlugin } from
|
|
6
|
-
import dotenv from
|
|
7
|
-
import { createRequire } from
|
|
1
|
+
import { defineConfig } from "@rspack/cli";
|
|
2
|
+
import { rspack } from "@rspack/core";
|
|
3
|
+
import path from "./paths.js";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
|
|
6
|
+
import dotenv from "dotenv";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
8
|
|
|
9
9
|
// 创建 require 函数用于 require.resolve
|
|
10
10
|
const require = createRequire(import.meta.url);
|
|
11
11
|
|
|
12
12
|
// 复用现有的环境变量加载逻辑
|
|
13
|
-
dotenv.config({ path: path.resolveApp(
|
|
13
|
+
dotenv.config({ path: path.resolveApp("./config/env/.env.public") });
|
|
14
14
|
|
|
15
15
|
let extraConfig = {};
|
|
16
16
|
try {
|
|
@@ -19,40 +19,41 @@ try {
|
|
|
19
19
|
extraConfig = dotenv.parse(fs.readFileSync(envFile));
|
|
20
20
|
}
|
|
21
21
|
} catch (error) {
|
|
22
|
-
console.warn(
|
|
22
|
+
console.warn("环境变量文件读取失败:", error.message);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
for (const key in extraConfig) {
|
|
26
26
|
process.env[key] = extraConfig[key];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const APP_CNAME = process.env.APP_CNAME ||
|
|
30
|
-
const APP_NAME = process.env.APP_NAME ||
|
|
31
|
-
const OUTPUT_PATH = process.env.OUTPUT_PATH ||
|
|
32
|
-
const PUBLIC_PATH = process.env.PUBLIC_PATH ||
|
|
29
|
+
const APP_CNAME = process.env.APP_CNAME || "Chat应用";
|
|
30
|
+
const APP_NAME = process.env.APP_NAME || "chat";
|
|
31
|
+
const OUTPUT_PATH = process.env.OUTPUT_PATH || "dist";
|
|
32
|
+
const PUBLIC_PATH = process.env.PUBLIC_PATH || "/";
|
|
33
33
|
|
|
34
34
|
export default defineConfig({
|
|
35
|
-
entry: [path.resolveApp(
|
|
35
|
+
entry: [path.resolveApp("./src/index")],
|
|
36
36
|
|
|
37
37
|
resolve: {
|
|
38
|
-
extensions: [
|
|
38
|
+
extensions: [".ts", ".tsx", ".jsx", ".js", ".json"],
|
|
39
39
|
alias: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
"@": path.resolveApp("./src"),
|
|
41
|
+
"@config": path.resolveApp("./config"),
|
|
42
|
+
"@store": path.resolveApp("./store"),
|
|
43
|
+
"@locales": path.resolveApp("./locales"),
|
|
44
|
+
"@public": path.resolveApp("./public"),
|
|
44
45
|
},
|
|
45
46
|
fallback: {
|
|
46
|
-
path: require.resolve(
|
|
47
|
-
process: require.resolve(
|
|
48
|
-
buffer: require.resolve(
|
|
49
|
-
util: require.resolve(
|
|
50
|
-
stream: require.resolve(
|
|
51
|
-
crypto: require.resolve(
|
|
52
|
-
zlib: require.resolve(
|
|
53
|
-
querystring: require.resolve(
|
|
54
|
-
url: require.resolve(
|
|
55
|
-
assert: require.resolve(
|
|
47
|
+
path: require.resolve("path-browserify"),
|
|
48
|
+
process: require.resolve("process/browser.js"),
|
|
49
|
+
buffer: require.resolve("buffer"),
|
|
50
|
+
util: require.resolve("util"),
|
|
51
|
+
stream: require.resolve("stream-browserify"),
|
|
52
|
+
crypto: require.resolve("crypto-browserify"),
|
|
53
|
+
zlib: require.resolve("browserify-zlib"),
|
|
54
|
+
querystring: require.resolve("querystring-es3"),
|
|
55
|
+
url: require.resolve("url"),
|
|
56
|
+
assert: require.resolve("assert"),
|
|
56
57
|
fs: false,
|
|
57
58
|
net: false,
|
|
58
59
|
tls: false,
|
|
@@ -67,28 +68,28 @@ export default defineConfig({
|
|
|
67
68
|
{
|
|
68
69
|
test: /\.[jt]sx?$/,
|
|
69
70
|
include: [
|
|
70
|
-
path.resolveApp(
|
|
71
|
-
path.resolveApp(
|
|
72
|
-
path.resolveApp(
|
|
73
|
-
path.resolveApp(
|
|
71
|
+
path.resolveApp("src"),
|
|
72
|
+
path.resolveApp("config"),
|
|
73
|
+
path.resolveApp("store"),
|
|
74
|
+
path.resolveApp("packages"),
|
|
74
75
|
],
|
|
75
|
-
exclude: [path.resolveApp(
|
|
76
|
+
exclude: [path.resolveApp("node_modules")],
|
|
76
77
|
use: [
|
|
77
78
|
{
|
|
78
|
-
loader:
|
|
79
|
+
loader: "builtin:swc-loader",
|
|
79
80
|
options: {
|
|
80
81
|
jsc: {
|
|
81
82
|
parser: {
|
|
82
|
-
syntax:
|
|
83
|
+
syntax: "typescript",
|
|
83
84
|
tsx: true,
|
|
84
85
|
decorators: true,
|
|
85
86
|
},
|
|
86
87
|
transform: {
|
|
87
88
|
react: {
|
|
88
|
-
runtime:
|
|
89
|
+
runtime: "automatic",
|
|
89
90
|
},
|
|
90
91
|
},
|
|
91
|
-
target:
|
|
92
|
+
target: "es2015",
|
|
92
93
|
},
|
|
93
94
|
sourceMaps: true,
|
|
94
95
|
},
|
|
@@ -96,10 +97,10 @@ export default defineConfig({
|
|
|
96
97
|
],
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
|
-
test: /\.(png|jpg|jpeg|gif|webp|m3u8|exr|hdr|json)$/,
|
|
100
|
-
include: [path.resolveApp(
|
|
101
|
-
exclude: [path.resolveApp(
|
|
102
|
-
type:
|
|
100
|
+
test: /\.(png|jpg|jpeg|gif|webp|m3u8|exr|hdr|json|woff2)$/,
|
|
101
|
+
include: [path.resolveApp("public")],
|
|
102
|
+
exclude: [path.resolveApp("src"), path.resolveApp("store")],
|
|
103
|
+
type: "asset",
|
|
103
104
|
parser: {
|
|
104
105
|
dataUrlCondition: {
|
|
105
106
|
maxSize: 10 * 1024,
|
|
@@ -107,33 +108,33 @@ export default defineConfig({
|
|
|
107
108
|
},
|
|
108
109
|
},
|
|
109
110
|
{
|
|
110
|
-
test: /\.md$/,
|
|
111
|
-
include: [path.resolveApp(
|
|
112
|
-
type:
|
|
111
|
+
test: /\.(md)$/,
|
|
112
|
+
include: [path.resolveApp("src")],
|
|
113
|
+
type: "asset/source",
|
|
113
114
|
},
|
|
114
115
|
{
|
|
115
116
|
test: /\.svg$/,
|
|
116
|
-
use: [
|
|
117
|
+
use: ["@svgr/webpack"],
|
|
117
118
|
},
|
|
118
119
|
],
|
|
119
120
|
},
|
|
120
121
|
|
|
121
122
|
plugins: [
|
|
122
123
|
new rspack.ProvidePlugin({
|
|
123
|
-
process:
|
|
124
|
-
Buffer: [
|
|
124
|
+
process: "process/browser.js",
|
|
125
|
+
Buffer: ["buffer", "Buffer"],
|
|
125
126
|
}),
|
|
126
127
|
new rspack.DefinePlugin({
|
|
127
|
-
|
|
128
|
+
"process.env": JSON.stringify(process.env),
|
|
128
129
|
// ["__CONVENTION_ROUTES__"]: JSON.stringify([]),
|
|
129
130
|
}),
|
|
130
131
|
new rspack.HtmlRspackPlugin({
|
|
131
|
-
template: path.resolveApp(
|
|
132
|
-
filename:
|
|
133
|
-
inject:
|
|
132
|
+
template: path.resolveApp("./public/index.html"),
|
|
133
|
+
filename: "index.html",
|
|
134
|
+
inject: "body",
|
|
134
135
|
hash: true,
|
|
135
|
-
minify: process.env.NODE_ENV ===
|
|
136
|
-
favicon: path.resolveApp(
|
|
136
|
+
minify: process.env.NODE_ENV === "production",
|
|
137
|
+
favicon: path.resolveApp("./public/favicon.ico"),
|
|
137
138
|
templateParameters: {
|
|
138
139
|
title: APP_CNAME,
|
|
139
140
|
mountRoot: APP_NAME,
|
|
@@ -142,8 +143,8 @@ export default defineConfig({
|
|
|
142
143
|
new rspack.CopyRspackPlugin({
|
|
143
144
|
patterns: [
|
|
144
145
|
{
|
|
145
|
-
from: path.resolveApp(
|
|
146
|
-
to:
|
|
146
|
+
from: path.resolveApp("./public/images"),
|
|
147
|
+
to: "public/images",
|
|
147
148
|
},
|
|
148
149
|
],
|
|
149
150
|
}),
|
|
@@ -165,11 +166,11 @@ export default defineConfig({
|
|
|
165
166
|
],
|
|
166
167
|
|
|
167
168
|
output: {
|
|
168
|
-
assetModuleFilename:
|
|
169
|
+
assetModuleFilename: "images/[hash][ext]",
|
|
169
170
|
library: `${APP_CNAME}-[name]`,
|
|
170
|
-
chunkFilename:
|
|
171
|
-
libraryTarget:
|
|
172
|
-
globalObject:
|
|
171
|
+
chunkFilename: "[name].[contenthash].js",
|
|
172
|
+
libraryTarget: "umd",
|
|
173
|
+
globalObject: "window",
|
|
173
174
|
chunkLoadingGlobal: `chunk_global_${APP_NAME}`,
|
|
174
175
|
publicPath: PUBLIC_PATH,
|
|
175
176
|
path: path.resolveApp(OUTPUT_PATH),
|
|
@@ -182,5 +183,5 @@ export default defineConfig({
|
|
|
182
183
|
},
|
|
183
184
|
],
|
|
184
185
|
|
|
185
|
-
devtool:
|
|
186
|
+
devtool: "source-map",
|
|
186
187
|
});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import path from './paths.js';
|
|
6
|
-
import { sentryWebpackPlugin } from '@sentry/webpack-plugin';
|
|
1
|
+
import { merge } from "webpack-merge";
|
|
2
|
+
import { rspack } from "@rspack/core";
|
|
3
|
+
import baseConfig from "./rspack.config.mjs";
|
|
4
|
+
import path from "./paths.js";
|
|
7
5
|
|
|
8
6
|
export default merge(baseConfig, {
|
|
9
|
-
mode:
|
|
10
|
-
devtool:
|
|
7
|
+
mode: "production",
|
|
8
|
+
devtool: "hidden-source-map",
|
|
11
9
|
|
|
12
10
|
output: {
|
|
13
|
-
filename:
|
|
14
|
-
chunkFilename:
|
|
11
|
+
filename: "[name].[contenthash].bundle.js",
|
|
12
|
+
chunkFilename: "[name].[contenthash].chunk.js",
|
|
15
13
|
clean: true,
|
|
16
14
|
},
|
|
17
15
|
|
|
@@ -29,18 +27,18 @@ export default merge(baseConfig, {
|
|
|
29
27
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
30
28
|
},
|
|
31
29
|
{
|
|
32
|
-
loader:
|
|
30
|
+
loader: "css-loader",
|
|
33
31
|
options: {
|
|
34
32
|
sourceMap: true,
|
|
35
33
|
},
|
|
36
34
|
},
|
|
37
35
|
{
|
|
38
|
-
loader:
|
|
36
|
+
loader: "less-loader",
|
|
39
37
|
options: {
|
|
40
38
|
sourceMap: true,
|
|
41
39
|
lessOptions: {
|
|
42
40
|
strictMath: false,
|
|
43
|
-
math:
|
|
41
|
+
math: "always",
|
|
44
42
|
javascriptEnabled: true,
|
|
45
43
|
},
|
|
46
44
|
},
|
|
@@ -50,8 +48,8 @@ export default merge(baseConfig, {
|
|
|
50
48
|
// Less 处理 - 项目文件
|
|
51
49
|
{
|
|
52
50
|
test: /\.less$/,
|
|
53
|
-
include: [path.resolveApp(
|
|
54
|
-
exclude: [path.resolveApp(
|
|
51
|
+
include: [path.resolveApp("src")],
|
|
52
|
+
exclude: [path.resolveApp("node_modules")],
|
|
55
53
|
oneOf: [
|
|
56
54
|
{
|
|
57
55
|
test: /\.module\.less$/,
|
|
@@ -60,17 +58,17 @@ export default merge(baseConfig, {
|
|
|
60
58
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
61
59
|
},
|
|
62
60
|
{
|
|
63
|
-
loader:
|
|
61
|
+
loader: "css-loader",
|
|
64
62
|
options: {
|
|
65
63
|
sourceMap: true,
|
|
66
64
|
modules: {
|
|
67
|
-
localIdentName:
|
|
65
|
+
localIdentName: "[path][name]__[local]--[hash:base64:5]",
|
|
68
66
|
},
|
|
69
67
|
importLoaders: 2,
|
|
70
68
|
},
|
|
71
69
|
},
|
|
72
70
|
{
|
|
73
|
-
loader:
|
|
71
|
+
loader: "less-loader",
|
|
74
72
|
options: {
|
|
75
73
|
sourceMap: true,
|
|
76
74
|
lessOptions: {
|
|
@@ -86,13 +84,13 @@ export default merge(baseConfig, {
|
|
|
86
84
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
87
85
|
},
|
|
88
86
|
{
|
|
89
|
-
loader:
|
|
87
|
+
loader: "css-loader",
|
|
90
88
|
options: {
|
|
91
89
|
sourceMap: true,
|
|
92
90
|
},
|
|
93
91
|
},
|
|
94
92
|
{
|
|
95
|
-
loader:
|
|
93
|
+
loader: "less-loader",
|
|
96
94
|
options: {
|
|
97
95
|
sourceMap: true,
|
|
98
96
|
lessOptions: {
|
|
@@ -107,8 +105,8 @@ export default merge(baseConfig, {
|
|
|
107
105
|
// Sass 处理
|
|
108
106
|
{
|
|
109
107
|
test: /\.s[ac]ss$/i,
|
|
110
|
-
include: [path.resolveApp(
|
|
111
|
-
exclude: [path.resolveApp(
|
|
108
|
+
include: [path.resolveApp("src")],
|
|
109
|
+
exclude: [path.resolveApp("node_modules")],
|
|
112
110
|
oneOf: [
|
|
113
111
|
{
|
|
114
112
|
test: /\.module\.s[ac]ss$/,
|
|
@@ -117,21 +115,21 @@ export default merge(baseConfig, {
|
|
|
117
115
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
118
116
|
},
|
|
119
117
|
{
|
|
120
|
-
loader:
|
|
118
|
+
loader: "css-loader",
|
|
121
119
|
options: {
|
|
122
120
|
sourceMap: true,
|
|
123
121
|
modules: {
|
|
124
|
-
localIdentName:
|
|
122
|
+
localIdentName: "[path][name]__[local]--[hash:base64:5]",
|
|
125
123
|
},
|
|
126
124
|
importLoaders: 2,
|
|
127
125
|
},
|
|
128
126
|
},
|
|
129
127
|
{
|
|
130
|
-
loader:
|
|
128
|
+
loader: "sass-loader",
|
|
131
129
|
options: {
|
|
132
130
|
sourceMap: true,
|
|
133
131
|
sassOptions: {
|
|
134
|
-
outputStyle:
|
|
132
|
+
outputStyle: "compressed",
|
|
135
133
|
},
|
|
136
134
|
},
|
|
137
135
|
},
|
|
@@ -143,17 +141,17 @@ export default merge(baseConfig, {
|
|
|
143
141
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
144
142
|
},
|
|
145
143
|
{
|
|
146
|
-
loader:
|
|
144
|
+
loader: "css-loader",
|
|
147
145
|
options: {
|
|
148
146
|
sourceMap: true,
|
|
149
147
|
},
|
|
150
148
|
},
|
|
151
149
|
{
|
|
152
|
-
loader:
|
|
150
|
+
loader: "sass-loader",
|
|
153
151
|
options: {
|
|
154
152
|
sourceMap: true,
|
|
155
153
|
sassOptions: {
|
|
156
|
-
outputStyle:
|
|
154
|
+
outputStyle: "compressed",
|
|
157
155
|
},
|
|
158
156
|
},
|
|
159
157
|
},
|
|
@@ -164,26 +162,26 @@ export default merge(baseConfig, {
|
|
|
164
162
|
// CSS 处理 - TailwindCSS
|
|
165
163
|
{
|
|
166
164
|
test: /\.css$/,
|
|
167
|
-
include: [path.resolveApp(
|
|
165
|
+
include: [path.resolveApp("src/index.css")],
|
|
168
166
|
use: [
|
|
169
167
|
{
|
|
170
168
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
171
169
|
},
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
"css-loader",
|
|
171
|
+
"postcss-loader",
|
|
174
172
|
],
|
|
175
173
|
},
|
|
176
174
|
// CSS 处理 - src 目录中的其他 CSS
|
|
177
175
|
{
|
|
178
176
|
test: /\.css$/,
|
|
179
|
-
include: [path.resolveApp(
|
|
180
|
-
exclude: [path.resolveApp(
|
|
177
|
+
include: [path.resolveApp("src")],
|
|
178
|
+
exclude: [path.resolveApp("src/index.css")],
|
|
181
179
|
use: [
|
|
182
180
|
{
|
|
183
181
|
loader: rspack.CssExtractRspackPlugin.loader,
|
|
184
182
|
},
|
|
185
183
|
{
|
|
186
|
-
loader:
|
|
184
|
+
loader: "css-loader",
|
|
187
185
|
options: {
|
|
188
186
|
sourceMap: true,
|
|
189
187
|
},
|
|
@@ -193,13 +191,13 @@ export default merge(baseConfig, {
|
|
|
193
191
|
// CSS 处理 - node_modules
|
|
194
192
|
{
|
|
195
193
|
test: /\.css$/,
|
|
196
|
-
include: [path.resolveApp(
|
|
194
|
+
include: [path.resolveApp("node_modules")],
|
|
197
195
|
use: [
|
|
198
196
|
{
|
|
199
|
-
loader:
|
|
197
|
+
loader: "style-loader",
|
|
200
198
|
},
|
|
201
199
|
{
|
|
202
|
-
loader:
|
|
200
|
+
loader: "css-loader",
|
|
203
201
|
options: {
|
|
204
202
|
sourceMap: true,
|
|
205
203
|
},
|
|
@@ -211,41 +209,22 @@ export default merge(baseConfig, {
|
|
|
211
209
|
|
|
212
210
|
plugins: [
|
|
213
211
|
new rspack.CssExtractRspackPlugin({
|
|
214
|
-
filename:
|
|
215
|
-
chunkFilename:
|
|
212
|
+
filename: "[name].[contenthash:8].css",
|
|
213
|
+
chunkFilename: "[name].[contenthash:8].chunk.css",
|
|
216
214
|
}),
|
|
217
|
-
|
|
218
|
-
// Sentry 插件 (仅生产环境)
|
|
219
|
-
process.env.SENTRY_ENABLED === 'true' &&
|
|
220
|
-
process.env.SENTRY_AUTH_TOKEN &&
|
|
221
|
-
sentryWebpackPlugin({
|
|
222
|
-
org: process.env.SENTRY_ORG,
|
|
223
|
-
project: process.env.SENTRY_PROJECT,
|
|
224
|
-
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
225
|
-
url: process.env.SENTRY_URL,
|
|
226
|
-
errorHandler: () => false,
|
|
227
|
-
}),
|
|
228
|
-
].filter(Boolean),
|
|
215
|
+
],
|
|
229
216
|
|
|
230
217
|
optimization: {
|
|
231
218
|
minimize: true,
|
|
232
219
|
minimizer: [
|
|
233
220
|
new rspack.SwcJsMinimizerRspackPlugin({
|
|
234
|
-
exclude: [path.resolveApp(
|
|
221
|
+
exclude: [path.resolveApp("node_modules")],
|
|
235
222
|
minimizerOptions: {
|
|
236
223
|
compress: {
|
|
237
|
-
pure_funcs: [
|
|
224
|
+
pure_funcs: ["console.info", "console.debug", "console.warn"],
|
|
238
225
|
drop_console: false,
|
|
239
226
|
drop_debugger: false,
|
|
240
227
|
},
|
|
241
|
-
mangle: {
|
|
242
|
-
reserved: [
|
|
243
|
-
'Sentry',
|
|
244
|
-
'initSentry',
|
|
245
|
-
'captureException',
|
|
246
|
-
'captureMessage',
|
|
247
|
-
],
|
|
248
|
-
},
|
|
249
228
|
},
|
|
250
229
|
}),
|
|
251
230
|
new rspack.LightningCssMinimizerRspackPlugin(),
|
|
@@ -59,20 +59,11 @@
|
|
|
59
59
|
"universal-cookie": "^8.0.1",
|
|
60
60
|
"url-join": "^5.0.0",
|
|
61
61
|
"uuid": "^11.0.3",
|
|
62
|
+
"zod": "^4.2.1",
|
|
62
63
|
"zustand": "^5.0.5",
|
|
63
64
|
"zustand-utils": "^2.1.1"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@babel/core": "^7.26.0",
|
|
67
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
68
|
-
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
69
|
-
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
70
|
-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
71
|
-
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
72
|
-
"@babel/preset-env": "^7.26.0",
|
|
73
|
-
"@babel/preset-react": "^7.25.9",
|
|
74
|
-
"@babel/runtime": "^7.26.0",
|
|
75
|
-
"@babel/runtime-corejs3": "^7.26.0",
|
|
76
67
|
"@biomejs/biome": "2.3.2",
|
|
77
68
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
78
69
|
"@rsdoctor/rspack-plugin": "^1.3.8",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
// typings.d.ts
|
|
2
|
-
declare module
|
|
3
|
-
declare module
|
|
4
|
-
declare module
|
|
5
|
-
declare module
|
|
6
|
-
declare module
|
|
7
|
-
declare module
|
|
8
|
-
declare module
|
|
2
|
+
declare module "*.css";
|
|
3
|
+
declare module "*.less";
|
|
4
|
+
declare module "*.png";
|
|
5
|
+
declare module "*.jpeg";
|
|
6
|
+
declare module "*.jpg";
|
|
7
|
+
declare module "*.scss";
|
|
8
|
+
declare module "*.woff";
|
|
9
|
+
declare module "*.woff2";
|
|
10
|
+
declare module "*.ttf";
|
|
11
|
+
declare module "*.eot";
|
|
12
|
+
declare module "*.otf";
|
|
13
|
+
declare module "*.svg" {
|
|
9
14
|
export function ReactComponent(
|
|
10
|
-
props: React.SVGProps<SVGSVGElement
|
|
15
|
+
props: React.SVGProps<SVGSVGElement>
|
|
11
16
|
): React.ReactElement;
|
|
12
17
|
const url: string;
|
|
13
18
|
export default url;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "dayjs/locale/zh-cn";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import { ConfigProvider } from "antd";
|
|
4
|
+
import { env } from "@/config/env";
|
|
5
|
+
|
|
6
|
+
interface BootstrapConfig {
|
|
7
|
+
appName: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 应用启动前的初始化配置
|
|
12
|
+
*/
|
|
13
|
+
export function bootstrap(config: BootstrapConfig) {
|
|
14
|
+
const { appName } = config;
|
|
15
|
+
|
|
16
|
+
// 配置 dayjs 国际化
|
|
17
|
+
dayjs.locale("zh-cn");
|
|
18
|
+
|
|
19
|
+
// 配置 antd 静态方法的前缀
|
|
20
|
+
ConfigProvider.config({
|
|
21
|
+
prefixCls: appName,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(`✅ Application [${appName}] bootstrapped successfully`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 使用环境变量初始化应用
|
|
29
|
+
*/
|
|
30
|
+
export function bootstrapWithEnv() {
|
|
31
|
+
bootstrap({
|
|
32
|
+
appName: env.APP_NAME,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 环境变量 Schema 定义
|
|
5
|
+
*/
|
|
6
|
+
const envSchema = z.object({
|
|
7
|
+
// Node 环境
|
|
8
|
+
NODE_ENV: z
|
|
9
|
+
.enum(["development", "test", "testDevelopment", "production"])
|
|
10
|
+
.default("development"),
|
|
11
|
+
|
|
12
|
+
// 应用配置
|
|
13
|
+
APP_NAME: z.string().min(1, "应用名称不能为空").default("app"),
|
|
14
|
+
APP_CNAME: z.string().default("应用"),
|
|
15
|
+
BASENAME: z.string().optional(),
|
|
16
|
+
|
|
17
|
+
// API 配置
|
|
18
|
+
API_PREFIX: z.string().default("/api"),
|
|
19
|
+
API_TIMEOUT: z
|
|
20
|
+
.string()
|
|
21
|
+
.transform(Number)
|
|
22
|
+
.pipe(z.number().positive())
|
|
23
|
+
.default(30000),
|
|
24
|
+
|
|
25
|
+
// Cookie 配置
|
|
26
|
+
COOKIE_NAME: z.string().default("access_token"),
|
|
27
|
+
|
|
28
|
+
// 其他配置
|
|
29
|
+
HELP_CENTER_URL: z.string().url().optional(),
|
|
30
|
+
OUTPUT_PATH: z.string().default("dist"),
|
|
31
|
+
PUBLIC_PATH: z.string().default("/"),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 安全解析环境变量(开发模式下使用默认值)
|
|
36
|
+
*/
|
|
37
|
+
function safeParseEnv() {
|
|
38
|
+
const result = envSchema.safeParse(process.env);
|
|
39
|
+
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
if (process.env.NODE_ENV === "production") {
|
|
42
|
+
// 生产环境严格校验
|
|
43
|
+
console.error("❌ 环境变量验证失败:");
|
|
44
|
+
result.error.issues.forEach((err) => {
|
|
45
|
+
console.error(` - ${err.path.join(".")}: ${err.message}`);
|
|
46
|
+
});
|
|
47
|
+
throw new Error("环境变量配置错误");
|
|
48
|
+
} else {
|
|
49
|
+
// 开发环境警告但不中断
|
|
50
|
+
console.warn("⚠️ 环境变量验证警告:");
|
|
51
|
+
result.error.issues.forEach((err) => {
|
|
52
|
+
console.warn(` - ${err.path.join(".")}: ${err.message}`);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result.success ? result.data : envSchema.parse({});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 导出类型安全的环境变量
|
|
62
|
+
*/
|
|
63
|
+
export const env = safeParseEnv();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 环境变量类型
|
|
67
|
+
*/
|
|
68
|
+
export type Env = z.infer<typeof envSchema>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 工具函数:判断是否为开发环境
|
|
72
|
+
*/
|
|
73
|
+
export const isDev = env.NODE_ENV === "development";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 工具函数:判断是否为生产环境
|
|
77
|
+
*/
|
|
78
|
+
export const isProd = env.NODE_ENV === "production";
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 工具函数:判断是否为测试环境
|
|
82
|
+
*/
|
|
83
|
+
export const isTest =
|
|
84
|
+
env.NODE_ENV === "test" || env.NODE_ENV === "testDevelopment";
|