@lemon-fe/vite-plugin-micro-frontend 1.1.9 → 1.2.1

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
@@ -39,6 +39,40 @@ declare function mfGeneratorPlugin(options: MfGeneratorOptions): VitePlugin;
39
39
  */
40
40
  declare function federationPlugin(federationOptions: FederationConfig): PluginOption[];
41
41
 
42
+ /**
43
+ * 生产构建动态 publicPath(类似 webpack `output.publicPath`)。
44
+ * 依赖 [vite-plugin-dynamic-base](https://github.com/chenxch/vite-plugin-dynamic-base);
45
+ * 生产环境请在应用的 `vite.config` 中使用占位 `base`,例如:
46
+ * `base: process.env.NODE_ENV === "production" ? "/__dynamic_base__/" : "/"`。
47
+ * 插件本身仅作用于 `vite build`(`apply: 'build'`),开发服务器不会启用。
48
+ *
49
+ * 推荐写法:只写「固定变量」取到的**动态域名**(`runtimeHostExpr`),应用路径与 Vite `base` 对齐(`appBase` 或与当前 `base` 一致)。
50
+ */
51
+ type DynamicBaseConfig = {
52
+ /** 传给 vite-plugin-dynamic-base,默认 true */
53
+ transformIndexHtml?: boolean;
54
+ transformIndexHtmlConfig?: {
55
+ insertBodyAfter?: boolean;
56
+ publicPath?: string;
57
+ };
58
+ /**
59
+ * 运行时代码表达式:求值为**域名或 origin 前缀**(不要包含应用 path),用于拼接真实 CDN/网关地址。
60
+ * 变量名固定(如 `window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST`),值为运行时动态域名。
61
+ * 示例:`"(window.EARTH_BASE_CONFIG && window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST ? window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST.replace(/\\\\/$/, '') : '') + '/app-earth-wms'"`
62
+ */
63
+ publicPath?: string;
64
+ /**
65
+ * 移除 HTML 中 `index-*.css` 的 link 与 dynamicBase 注入的对应 preload(样式全部由 JS 注入时使用)。
66
+ */
67
+ removeIndexCssPreload?: boolean;
68
+ };
69
+
70
+ /**
71
+ * 生产构建专用:动态 publicPath(vite-plugin-dynamic-base + 可选 HTML 兜底)。
72
+ * 仅 `vite build` 生效,与 {@link MicroFrontendPluginOptions.dynamicBase} 配合使用。
73
+ */
74
+ declare function getDynamicBasePlugins(options: DynamicBaseConfig | boolean): PluginOption[];
75
+
42
76
  declare function autoExternalAntd(): Plugin;
43
77
 
44
78
  /**
@@ -159,6 +193,8 @@ interface MicroFrontendPluginOptions {
159
193
  /** qiankun 应用名称 */
160
194
  name?: string;
161
195
  };
196
+ /** 生产构建启用动态资源路径;未配置则不注册 */
197
+ dynamicBase?: DynamicBaseConfig | boolean;
162
198
  }
163
199
  type VitePlugin = Plugin;
164
200
 
@@ -211,5 +247,5 @@ declare function getRoutes(opts: IOpts): IRoute[];
211
247
  declare const MICRO_FRONTEND_OPTIONS_KEY = "__microFrontendOptions";
212
248
  declare function microFrontendPlugins(options: MicroFrontendPluginOptions): PluginOption[];
213
249
 
214
- export { MICRO_FRONTEND_OPTIONS_KEY, autoExternalAntd, devHmrPlugin, federationPlugin, generateMf, generateRoutesToFile, getRoutes, mfGeneratorPlugin, microFrontendPlugins, pagesRoutesPlugin };
215
- export type { ComponentMetadata, FederationConfig, IRoute, MfGeneratorOptions, MicroFrontendPluginOptions, RemoteConfig, RouteConfig, RoutesPluginOptions, RoutesTemplateOptions, VitePlugin };
250
+ export { MICRO_FRONTEND_OPTIONS_KEY, autoExternalAntd, devHmrPlugin, federationPlugin, generateMf, generateRoutesToFile, getDynamicBasePlugins, getRoutes, mfGeneratorPlugin, microFrontendPlugins, pagesRoutesPlugin };
251
+ export type { ComponentMetadata, DynamicBaseConfig, FederationConfig, IRoute, MfGeneratorOptions, MicroFrontendPluginOptions, RemoteConfig, RouteConfig, RoutesPluginOptions, RoutesTemplateOptions, VitePlugin };