ptech-preset 1.2.6 → 1.2.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/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type MfAutoOptions = {
|
|
|
13
13
|
stylesExposeKey?: string;
|
|
14
14
|
separateExposes?: boolean;
|
|
15
15
|
separateExposeChunkPrefix?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** thư mục chứa types đã consume; mặc định "@mf-types" */
|
|
17
17
|
typesFolder?: string;
|
|
18
18
|
/** env để ép refresh types ở dev (khởi động lại dev) */
|
|
19
19
|
devTypesRefreshEnvVar?: string;
|
package/dist/index.js
CHANGED
|
@@ -323,8 +323,8 @@ function pluginCore(opts) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
const command = api?.context?.command;
|
|
326
|
-
const
|
|
327
|
-
const isDev = !
|
|
326
|
+
const isProdLike = command === "build" || process.env.NODE_ENV === "production";
|
|
327
|
+
const isDev = !isProdLike;
|
|
328
328
|
const autoTypeUrls = buildRemoteTypeUrls(mfMerged.remotes || {});
|
|
329
329
|
if (isDev) {
|
|
330
330
|
const refresh = process.env[devTypesRefreshEnvVar] === "1";
|
|
@@ -359,7 +359,7 @@ function pluginCore(opts) {
|
|
|
359
359
|
dtsObj.consumeTypes = {
|
|
360
360
|
typesFolder: existingConsume.typesFolder ?? typesFolder,
|
|
361
361
|
maxRetries: existingConsume.maxRetries ?? 3,
|
|
362
|
-
// ưu tiên config hiện hữu nếu
|
|
362
|
+
// ưu tiên config hiện hữu nếu trùng key
|
|
363
363
|
remoteTypeUrls: { ...autoTypeUrls, ...existingRt }
|
|
364
364
|
};
|
|
365
365
|
}
|
|
@@ -370,11 +370,14 @@ function pluginCore(opts) {
|
|
|
370
370
|
const mfPlugin = pluginModuleFederation(mfMerged);
|
|
371
371
|
await mfPlugin.setup?.(api);
|
|
372
372
|
const pkgSafe = getPackageName(root) || mfMerged.name || path3.basename(root).replace(/\W+/g, "");
|
|
373
|
-
const cdnUrl = `${CDN_BASE}${pkgSafe}/`;
|
|
374
373
|
api.modifyRsbuildConfig((config) => {
|
|
375
374
|
config.output ??= {};
|
|
376
|
-
|
|
377
|
-
|
|
375
|
+
const current = config.output.assetPrefix;
|
|
376
|
+
const fromEnv = process.env.CDN_URL || process.env.ASSET_PREFIX;
|
|
377
|
+
const fallbackCdn = `${CDN_BASE}${pkgSafe}/`;
|
|
378
|
+
const target = fromEnv ?? fallbackCdn;
|
|
379
|
+
if (isProdLike && (!current || current === "/" || current === "./")) {
|
|
380
|
+
config.output.assetPrefix = target;
|
|
378
381
|
}
|
|
379
382
|
return config;
|
|
380
383
|
});
|