@lark-apaas/fullstack-rspack-preset 1.0.30-alpha.1 → 1.0.30-alpha.2
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/lib/overlay/index.js +27 -5
- package/lib/preset.js +20 -9
- package/package.json +2 -2
package/lib/overlay/index.js
CHANGED
|
@@ -129,13 +129,35 @@ function removeAllChildren(element, skip) {
|
|
|
129
129
|
element.removeChild(childList[i]);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
// 获取父窗口 origin
|
|
133
|
+
function getPreviewParentOrigin() {
|
|
134
|
+
const { origin } = window.location;
|
|
135
|
+
if (origin.includes('force.feishuapp.net')) {
|
|
136
|
+
return 'https://force.feishu.cn';
|
|
137
|
+
}
|
|
138
|
+
if (origin.includes('force-pre.feishuapp.net')) {
|
|
139
|
+
return 'https://force.feishu-pre.cn';
|
|
140
|
+
}
|
|
141
|
+
// force BOE环境
|
|
142
|
+
if (origin.includes('force.byted.org')) {
|
|
143
|
+
return 'https://force.feishu-boe.cn';
|
|
144
|
+
}
|
|
145
|
+
// MIAODA 线上环境
|
|
146
|
+
if (origin.includes('feishuapp.cn') ||
|
|
147
|
+
origin.includes('miaoda.feishuapp.net')) {
|
|
148
|
+
return 'https://miaoda.feishu.cn';
|
|
149
|
+
}
|
|
150
|
+
// MIAODA PRE 环境
|
|
151
|
+
if (origin.includes('fsapp.kundou.cn') ||
|
|
152
|
+
origin.includes('miaoda-pre.feishuapp.net')) {
|
|
153
|
+
return 'https://miaoda.feishu-pre.cn';
|
|
154
|
+
}
|
|
155
|
+
// MIAODA BOE 环境
|
|
156
|
+
return 'https://miaoda.feishu-boe.cn';
|
|
157
|
+
}
|
|
132
158
|
function sendPostMessage(message, targetOrigin) {
|
|
133
159
|
try {
|
|
134
|
-
const
|
|
135
|
-
const origin = targetOrigin || parentOrigin;
|
|
136
|
-
if (!origin) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
160
|
+
const origin = targetOrigin || getPreviewParentOrigin();
|
|
139
161
|
window.parent.postMessage(message, origin);
|
|
140
162
|
}
|
|
141
163
|
catch (error) {
|
package/lib/preset.js
CHANGED
|
@@ -146,7 +146,6 @@ function createRecommendRspackConfig(options) {
|
|
|
146
146
|
'process.env.NODE_ENV': JSON.stringify(isDev ? 'development' : 'production'),
|
|
147
147
|
'process.env.runtimeMode': JSON.stringify('fullstack'),
|
|
148
148
|
'process.env.CLIENT_BASE_PATH': JSON.stringify(clientBasePath),
|
|
149
|
-
'process.env.FORCE_FRAMEWORK_DOMAIN_MAIN': JSON.stringify(process.env.FORCE_FRAMEWORK_DOMAIN_MAIN ?? ''),
|
|
150
149
|
'process.env.CWD': JSON.stringify(''),
|
|
151
150
|
// 解决 window 未定义问题
|
|
152
151
|
'typeof window': JSON.stringify('object'),
|
|
@@ -193,7 +192,7 @@ function createRecommendRspackConfig(options) {
|
|
|
193
192
|
? {}
|
|
194
193
|
: {
|
|
195
194
|
moduleIds: 'deterministic',
|
|
196
|
-
concatenateModules:
|
|
195
|
+
concatenateModules: false, // 1.6.8 中 echarts + rspack 会 panic
|
|
197
196
|
minimize: true, // 对应vite的minify配置
|
|
198
197
|
minimizer: [
|
|
199
198
|
new core_1.default.SwcJsMinimizerRspackPlugin({
|
|
@@ -266,13 +265,25 @@ function createRecommendRspackConfig(options) {
|
|
|
266
265
|
},
|
|
267
266
|
overlay: false,
|
|
268
267
|
},
|
|
269
|
-
headers: (
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
headers: (req) => {
|
|
269
|
+
// 获取请求的Origin头
|
|
270
|
+
const requestOrigin = req.headers.origin ?? '';
|
|
271
|
+
// 定义允许的域名白名单
|
|
272
|
+
const allowedOrigins = [
|
|
273
|
+
'https://force.feishu-boe.cn',
|
|
274
|
+
'https://force.feishu.cn',
|
|
275
|
+
'https://force.feishu-pre.cn',
|
|
276
|
+
'https://miaoda.feishu.cn',
|
|
277
|
+
'https://miaoda.feishu-boe.cn',
|
|
278
|
+
'https://miaoda.feishu-pre.cn',
|
|
279
|
+
];
|
|
280
|
+
// 检查请求的Origin是否在允许的列表中
|
|
281
|
+
const allowedOrigin = allowedOrigins.includes(requestOrigin)
|
|
282
|
+
? requestOrigin
|
|
283
|
+
: allowedOrigins[0]; // 默认返回第一个允许的域名
|
|
284
|
+
return {
|
|
285
|
+
'Access-Control-Allow-Origin': allowedOrigin,
|
|
286
|
+
};
|
|
276
287
|
},
|
|
277
288
|
onListening(server) {
|
|
278
289
|
(0, dev_server_listener_1.listenHmrTiming)(server);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-rspack-preset",
|
|
3
|
-
"version": "1.0.30-alpha.
|
|
3
|
+
"version": "1.0.30-alpha.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"patches",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/parser": "^7.28.0",
|
|
32
32
|
"@babel/traverse": "^7.28.0",
|
|
33
33
|
"@babel/types": "^7.28.2",
|
|
34
|
-
"@lark-apaas/devtool-kits": "1.2.
|
|
34
|
+
"@lark-apaas/devtool-kits": "^1.2.13",
|
|
35
35
|
"@lark-apaas/miaoda-inspector-babel-plugin": "^1.0.0",
|
|
36
36
|
"@lark-apaas/miaoda-inspector-jsx-runtime": "^1.0.0",
|
|
37
37
|
"@rspack/plugin-react-refresh": "^1.5.1",
|