Skip to content
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

feature: SSR模式下,多输出一份和index.html完全一致的*.html文件,用于ER场景 #11723

Merged
merged 20 commits into from
Oct 11, 2023

Conversation

gwuhaolin
Copy link
Member

@gwuhaolin gwuhaolin commented Oct 11, 2023

image 如图会输出两个一样的html文件

奇风 and others added 19 commits October 8, 2023 12:00
@vercel
Copy link

vercel bot commented Oct 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
umi ⬜️ Ignored (Inspect) Visit Preview Oct 11, 2023 8:45am

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (0c77630) 28.94% compared to head (a55b708) 28.94%.
Report is 4 commits behind head on master.

❗ Current head a55b708 differs from pull request most recent head d572247. Consider uploading reports for the commit d572247 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11723      +/-   ##
==========================================
- Coverage   28.94%   28.94%   -0.01%     
==========================================
  Files         485      485              
  Lines       14765    14767       +2     
  Branches     3497     3498       +1     
==========================================
  Hits         4274     4274              
- Misses       9731     9733       +2     
  Partials      760      760              
Files Coverage Δ
packages/preset-umi/src/commands/build.ts 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sorrycc sorrycc merged commit 405176d into umijs:master Oct 11, 2023
2 of 22 checks passed
@@ -145,6 +145,11 @@ export default function handler(request, response) {
}
});

api.onBuildHtmlComplete(() => {
// SSR模式下,多输出一份和index.html完全一致的*.html文件,用于ER场景
fsExtra.copyFileSync(join(api.paths.absOutputPath, 'index.html'), join(api.paths.absOutputPath, '*.html'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方非常不清真。

  1. 首先这是用户非预期的文件,我们不应该生成大部分用户不需要的文件,这部分特定于 serverless 的可以做到 bigfish 里或者单独的 serverless plugin 或 preset 里去,而不应该污染源代码库造成所有人都有这个副作用。

  2. 其次有的人可能对 html 产物做了修改,这里复制了 index.html 其实用户会得到两个不一样的 html 产物,会造成非常大的疑惑,是黑盒。

  3. 另外标准存在不一致,社区内对于 404 fallback 的默认行为是 找不到会使用 404.html ,而这里是 *.html ,不符合社区共识。

改进意见

  1. 做到 bigfish 中或内部自己的 serverless umi plugin or preset 中,不要污染 umi 代码仓库造成所有人的副作用和非预期黑盒产物。

  1. 新增选项 ssr: { er: true } 选项来开启这个生成功能,以后所有的副作用做到这个选项开启内。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants