-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 支持htmlSuffix、dynamicRoot #12496
base: master
Are you sure you want to change the base?
Conversation
htmlSuffix 会生成 xxx.html,非xxx/index.html dynamicRoot可不用做任何修改部署在任意目录下
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough此次变更引入了针对静态文件导出的配置,包括HTML后缀、动态根路径和散列处理的设置。新增和修改的文件涵盖了页面组件、样式文件及核心控制逻辑,优化了静态导出功能的处理流程。 Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (9)
- examples/export-static/.umirc.ts (1 hunks)
- examples/export-static/package.json (1 hunks)
- examples/export-static/src/pages/404.tsx (1 hunks)
- examples/export-static/src/pages/bar.css (1 hunks)
- examples/export-static/src/pages/foo.less (1 hunks)
- examples/export-static/src/pages/index.tsx (1 hunks)
- examples/export-static/src/pages/page1/index.tsx (1 hunks)
- examples/export-static/src/pages/page1/page1_1/index.tsx (1 hunks)
- packages/preset-umi/src/features/exportStatic/exportStatic.ts (8 hunks)
Files skipped from review due to trivial changes (7)
- examples/export-static/.umirc.ts
- examples/export-static/package.json
- examples/export-static/src/pages/404.tsx
- examples/export-static/src/pages/bar.css
- examples/export-static/src/pages/foo.less
- examples/export-static/src/pages/page1/index.tsx
- examples/export-static/src/pages/page1/page1_1/index.tsx
Additional context used
Biome
packages/preset-umi/src/features/exportStatic/exportStatic.ts
[error] 92-92: The regular expression includes this negated empty character class. (lint/correctness/noEmptyCharacterClassInRegex)
Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.
[error] 92-92: The regular expression includes this negated empty character class. (lint/correctness/noEmptyCharacterClassInRegex)
Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.
[error] 94-94: The regular expression includes this negated empty character class. (lint/correctness/noEmptyCharacterClassInRegex)
Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.
[error] 355-355: Can't assign key because it's a constant (lint/correctness/noConstAssign)
This is where the variable is defined as constant
Unsafe fix: Replace const with let if you assign it to a new value.
Additional comments not posted (2)
examples/export-static/src/pages/index.tsx (1)
9-34
: 代码审查:确保链接的正确性这个
HomePage
组件中包含了多个链接,指向不同的页面。由于引入了htmlSuffix
功能,需要确保这些链接在启用htmlSuffix
时仍然有效。建议添加单元测试来验证这些链接在不同配置下的行为。packages/preset-umi/src/features/exportStatic/exportStatic.ts (1)
Line range hint
171-362
: 验证动态根路径和 HTML 后缀的处理在
modifyExportHTMLFiles
函数中,处理了动态根路径和 HTML 后缀的逻辑。需要验证这些逻辑是否正确处理了所有边界情况,特别是在复杂的路由配置中。Verification successful
验证动态根路径和 HTML 后缀的处理
代码逻辑正确处理了动态根路径和 HTML 后缀,包括路径调整和必要的断言,确保在复杂路由配置中也能正常工作。
- 处理相对路径
publicPath
和dynamicRoot
的逻辑- 确保在需要时启用
runtimePublicPath
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 检查动态根路径和 HTML 后缀的处理是否正确 rg --type ts "dynamicRoot" packages/preset-umi/src/features/exportStatic/exportStatic.tsLength of output: 424
Script:
#!/bin/bash # Extract the relevant code blocks around each occurrence of `dynamicRoot` for detailed review # Extract 10 lines before and after the first occurrence rg --type ts -A 10 -B 10 "dynamicRoot: zod.boolean()" packages/preset-umi/src/features/exportStatic/exportStatic.ts # Extract 10 lines before and after the second occurrence rg --type ts -A 10 -B 10 "exportStatic: { htmlSuffix, dynamicRoot }" packages/preset-umi/src/features/exportStatic/exportStatic.ts # Extract 10 lines before and after the third occurrence rg --type ts -A 10 -B 10 "publicPath.startsWith('.') || dynamicRoot" packages/preset-umi/src/features/exportStatic/exportStatic.ts # Extract 10 lines before and after the fourth occurrence rg --type ts -A 10 -B 10 "'`runtimePublicPath` should be enable when `publicPath` is relative or `exportStatic.dynamicRoot` is true!'" packages/preset-umi/src/features/exportStatic/exportStatic.tsLength of output: 12138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (1)
- packages/preset-umi/src/features/exportStatic/exportStatic.ts (7 hunks)
Additional context used
Biome
packages/preset-umi/src/features/exportStatic/exportStatic.ts
[error] 328-328: Can't assign key because it's a constant
This is where the variable is defined as constant
Unsafe fix: Replace const with let if you assign it to a new value.
(lint/correctness/noConstAssign)
Additional comments not posted (3)
packages/preset-umi/src/features/exportStatic/exportStatic.ts (3)
41-47
: 代码逻辑清晰,路径处理正确。
Line range hint
52-73
: 对于静态文件路径的处理符合新功能的要求。
136-137
: 新配置项添加正确,符合功能需求。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/preset-umi/src/features/exportStatic/exportStatic.ts (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/preset-umi/src/features/exportStatic/exportStatic.ts
修复配置式路由中path以'.html' 结束的场景不生成html文件bug
这个feat啥时候才能合并呢 |
急需这个功能.非常好用 |
这个feat啥时候才能合并呢 |
公司好几个项目升级umi4.x需要用到,希望能支持 #12301
有一点需要说明的是
dynamicRoot 为新增配置,原publicPath: './'相对路径的方式也是有问题的,使用当前规则没问题。
对于
dynamicRoot:true, htmlSuffix: false
的场景,由于/page1 和 /page1/index.html 得到的相对路径不一样,但是又是同一个文件,对于headScripts等脚本路径是编译时确定的,没办法对前面两个路由同时生效。{ dynamicRoot:true, htmlSuffix: true }
使用 /page1、/page1.html 访问{ dynamicRoot:true, htmlSuffix: false }
使用 /page1/、/page1/index.html 访问已添加examples/export-static项目,且测试以下场景都正常:
① 约定式路由,不开启 dynamicRoot 、不开启 htmlSuffix 。
② 约定式路由,开启 dynamicRoot 、不开启 htmlSuffix 。
③ 约定式路由,不开启 dynamicRoot 、开启 htmlSuffix 。
④ 约定式路由,开启 dynamicRoot 、开启 htmlSuffix 。
⑤ 配置式路由,不开启 dynamicRoot 、不开启 htmlSuffix 。
⑥ 配置式路由,开启 dynamicRoot 、不开启 htmlSuffix 。
⑦ 配置式路由,不开启 dynamicRoot 、开启 htmlSuffix 。
⑧ 配置式路由,开启 dynamicRoot 、开启 htmlSuffix 。
使用Whistle测试,对应
htmlSuffix: true
配置:htmlSuffix: false
配置:之前的PR已关闭,感谢 @fz6m 的修改意见,详见:#12400
Summary by CodeRabbit
新功能
样式
.bar
类的绿色背景样式。.foo
、.foo2
和.foo3
类的颜色、字体大小和字体粗细样式。文档
package.json
文件,增加了构建、开发、设置和启动项目的脚本配置。