Skip to content

Commit 3a5bbc5

Browse files
committed
fix: ghpage 404
1 parent 83b7419 commit 3a5bbc5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

plugin.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { copyFileSync, existsSync } from 'fs';
2+
import { join } from 'path';
3+
import { IApi } from 'umi';
4+
5+
export default (api: IApi) => {
6+
api.onBuildComplete(({ err }) => {
7+
//@ts-ignore
8+
if (!err && !existsSync(join(api.paths.absOutputPath!, '404.html'))) {
9+
// 如果没有 404 则复制一下 index
10+
setTimeout(() => {
11+
copyFileSync(
12+
join(api.paths.absOutputPath!, 'index.html'),
13+
join(api.paths.absOutputPath!, '404.html'),
14+
);
15+
}, 500);
16+
}
17+
});
18+
};

0 commit comments

Comments
 (0)