Skip to content

Commit

Permalink
feat: exportStatic support supportWin config (umijs#7713)
Browse files Browse the repository at this point in the history
* feat: exportStatic support supportWin config

* alway close

* fix tsc

* try fix
  • Loading branch information
chenshuai2144 authored Dec 21, 2021
1 parent d855830 commit 820440f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/Config/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface BaseIConfig {
exportStatic?: {
htmlSuffix?: boolean;
dynamicRoot?: boolean;
supportWin?: boolean;
};
}

Expand Down
21 changes: 21 additions & 0 deletions packages/preset-built-in/src/plugins/features/exportStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default (api: IApi) => {
return joi.object({
htmlSuffix: joi.boolean(),
dynamicRoot: joi.boolean(),
/**
* 在 windows 下面不要生成 .uuid.html
*/
supportWin: joi.boolean(),
// 不能通过直接 patch 路由的方式,拿不到 match.[id],是一个 render paths 的概念
extraRoutePaths: joi
.function()
Expand Down Expand Up @@ -52,6 +56,10 @@ export default (api: IApi) => {
}
});

/**
* 不知道为啥有这个,会导致这个问题
* https://github.com/ant-design/ant-design-pro/issues/9441
*/
if (rootIndex !== null) {
routes.splice(rootIndex, 0, {
...routes[rootIndex],
Expand All @@ -78,6 +86,19 @@ export default (api: IApi) => {
},
file: html.getHtmlPath(path),
});
/**
* supportWin 打开之后下面不要生成 .uuid.html
* 为什么不单独设置windows?
* 因为 mac 下面生成了 .uuid.html,在 windows 下面 clone 不下来。
*/
if (
api.config.exportStatic &&
//@ts-ignore
api.config.exportStatic?.supportWin &&
path.includes(':')
) {
return;
}
routeMap.push(newPath);
}
});
Expand Down
1 change: 1 addition & 0 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ export interface BaseIConfig extends IConfigCore {
exportStatic?: {
htmlSuffix?: boolean;
dynamicRoot?: boolean;
supportWin?: boolean;
extraRoutePaths?: () => Promise<string[]>;
};
externals?: any;
Expand Down

0 comments on commit 820440f

Please sign in to comment.