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 CHANGED
@@ -13,7 +13,7 @@ type MfAutoOptions = {
13
13
  stylesExposeKey?: string;
14
14
  separateExposes?: boolean;
15
15
  separateExposeChunkPrefix?: string;
16
- /** tên folder chứa types đã consume; mặc định "@mf-types" */
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 isProd = process.env.NODE_ENV === "production" || command === "build";
327
- const isDev = !isProd;
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 đụng key
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
- if (!config.output.assetPrefix && process.env.NODE_ENV === "production") {
377
- config.output.assetPrefix = cdnUrl;
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ptech-preset",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Auto Module.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",