Replies: 1 comment
-
|
Umi4 没有直接的配置项来修改 但针对你的两个问题分别回答: 1. 直接对打包后的 index.html 改名会有问题吗? 大部分情况下不会有问题,但需要注意以下几点:
2. 如果想自动化改名,推荐在构建脚本中处理: 在 {
"scripts": {
"build": "umi build && mv dist/index.html dist/app.html"
}
}或者写一个 Umi 插件,在 // plugin.ts
import { IApi } from 'umi';
import { renameSync } from 'fs';
import { join } from 'path';
export default (api: IApi) => {
api.onBuildComplete(({ err }) => {
if (!err) {
const dist = api.paths.absOutputPath;
renameSync(join(dist, 'index.html'), join(dist, 'app.html'));
}
});
};然后在配置中引入: // .umirc.ts
export default {
plugins: ['./plugin.ts'],
};3. 补充:如果你的需求是为每个路由生成独立的 HTML 文件 可以使用 export default {
exportStatic: {},
// 或者带 .html 后缀
// exportStatic: { htmlSuffix: true },
};这样 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
项目可能有需求,但是找了一些配置都是umi3的,umi4支持吗?有类似的方法吗?
Beta Was this translation helpful? Give feedback.
All reactions