@mbws/plugin-sdk 0.3.1 → 0.3.3
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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vite.js +11 -1
- package/package.json +1 -1
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -32,6 +32,16 @@ const DEFAULT_API_BASE = "https://union.mobiwusi.com";
|
|
|
32
32
|
function resolveApiBase(config) {
|
|
33
33
|
return (config.apiBaseUrl ?? process.env.MBWS_API_BASE_URL ?? DEFAULT_API_BASE).replace(/\/+$/, "");
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* 官方附件库地址(**构建期**解析 platforms hash 用):env > 线上,**刻意不走
|
|
37
|
+
* config.apiBaseUrl**——它是本地联调字段,而附件库是平台生产设施,产物 hash 必须
|
|
38
|
+
* 钉生产库(在线构建容器里按本地地址 fetch 会不可达)。
|
|
39
|
+
* dev 侧(spawn 附件下载 / dev manifest)直接用 resolveApiBase:dev 跑在开发者
|
|
40
|
+
* 本机,apiBaseUrl 指向的本地后端就是正确地址,免导环境变量。
|
|
41
|
+
*/
|
|
42
|
+
function attachmentApiBase() {
|
|
43
|
+
return (process.env.MBWS_API_BASE_URL ?? DEFAULT_API_BASE).replace(/\/+$/, "");
|
|
44
|
+
}
|
|
35
45
|
/** 读请求体(POST 等带 body 的转发用;GET/HEAD 直接跳过) */
|
|
36
46
|
function readRequestBody(req) {
|
|
37
47
|
return new Promise((resolve, reject) => {
|
|
@@ -182,7 +192,7 @@ export function mbwsVitePlugin(opts) {
|
|
|
182
192
|
// mkdir 容错:在线构建场景 outDir 被平台覆盖,本目录可能不存在(写失败会炸构建)
|
|
183
193
|
fs.mkdirSync(outDir, { recursive: true });
|
|
184
194
|
const refs = config.attachments ?? [];
|
|
185
|
-
const decls = refs.length > 0 ? await resolveAttachmentRefs(refs,
|
|
195
|
+
const decls = refs.length > 0 ? await resolveAttachmentRefs(refs, attachmentApiBase()) : [];
|
|
186
196
|
fs.writeFileSync(path.join(outDir, "manifest.json"), `${JSON.stringify(buildManifest(config, { resolvedAttachments: decls }), null, 2)}\n`);
|
|
187
197
|
},
|
|
188
198
|
};
|