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

Improve document generate and deploy workflow #731

Merged
merged 5 commits into from
Jul 27, 2018

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented Jul 25, 2018

TODO

  • 补充 html 的 context
  • 重构 html generator
  • runtimePublicPath
  • 补充 plugin hooks

html context

  • 全局 context
  • page 级 context
  • config
  • webpackConfig
  • env: development | production
  • route

插件可以提供额外 context。

关于部署

  1. 默认输出一个 HTML 文件,然后所有 js 文件打包在一起,不按需加载
  2. 不想要 HTML 文件,可以配置环境变量 HTML=none
  3. HTML 部署到非根目录时,在 .umirc.js 里配置 base
  4. js/css 部署到非根目录或者 cdn 时,在 .umirc.js 里配置 publicPath
  5. 默认是 browser history,如需使用 hash history,在 .umirc.js 里配 history: 'hash'
  6. 自己管理 HTML 文件,并且 publicPath 不是打包时可以决定的值时,在 .umirc.js 里配置 runtimePublicPath: true,然后在 HTML 里输出 window.publicPath = <%= YOUR PUBLIC_PATH %>;
  7. 要实现按需加载,使用 umi-plugin-react,并配上 dynamicImport: {},dynamicImport 有两个配置项,1) 是 loadingComponent,可以指定页面加载时的 loading 组件,2) 是 webpackChunkName,可以让打包后的文件名更有意义,而不是 1.async.js, 2.async.js 等
  8. 要导出所有路由的 HTML 文件,在 .umirc.js 里配 exportStatic: {},exportStatic 有两个配置项,1) 是 htmlSuffix 表示是否给路由加上 .html 后缀,适用于有些服务器不会自动找 index.html 的索引文件,2)是 dynamicRoot,这时需要把 html、css、js 等部署在一个地方,然后可以在任意路径打开

冲突的配置项

  1. hashHistory 和 exportStatic 不能同时用
  2. exportStatic 时不能用动态路由

@coveralls
Copy link

coveralls commented Jul 25, 2018

Pull Request Test Coverage Report for Build 916

  • 107 of 138 (77.54%) changed or added relevant lines in 7 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+2.6%) to 29.673%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/umi-build-dev/src/getConfig/configPlugins/exportStatic.js 0 1 0.0%
packages/umi-build-dev/src/plugins/404/index.js 0 1 0.0%
packages/umi-build-dev/src/plugins/commands/dev/createRouteMiddleware.js 0 2 0.0%
packages/umi-build-dev/src/plugins/commands/build/index.js 0 2 0.0%
packages/umi-build-dev/src/plugins/commands/getHtmlGenerator.js 0 3 0.0%
packages/umi-build-dev/src/html/HTMLGenerator.js 104 126 82.54%
Files with Coverage Reduction New Missed Lines %
packages/umi-build-dev/src/plugins/commands/dev/createRouteMiddleware.js 1 0.0%
Totals Coverage Status
Change from base Build 901: 2.6%
Covered Lines: 747
Relevant Lines: 2604

💛 - Coveralls

@sorrycc sorrycc changed the title WIP: Improve document generate WIP: Improve document generate and deploy workflow Jul 27, 2018
@sorrycc sorrycc merged commit c6b9527 into master Jul 27, 2018
@sorrycc sorrycc deleted the improve-document-generate branch July 27, 2018 06:49
@sorrycc sorrycc changed the title WIP: Improve document generate and deploy workflow Improve document generate and deploy workflow Jul 27, 2018
@sorrycc sorrycc mentioned this pull request Aug 8, 2018
sorrycc pushed a commit that referenced this pull request Jun 23, 2022
* docs: 📝  介绍调整位置

* refactor: 🎨 用词修改

* chore: ✏️ capital case

* docs: 📝  use quote

* chore: ✏️  格式调整

* chore: ✏️ 大小写调整

* chore: 🎨 prettier

* docs: 📝  prettier

* docs: 📝 data-flow 更新

* docs: 📝 调整 i18n 文档

* refactor: 🔥 remove extra space

Co-authored-by: pshu <pishu.spf@antfin.com>
xierenyuan pushed a commit to xierenyuan/umi that referenced this pull request Jun 23, 2022
* docs: 📝  介绍调整位置

* refactor: 🎨 用词修改

* chore: ✏️ capital case

* docs: 📝  use quote

* chore: ✏️  格式调整

* chore: ✏️ 大小写调整

* chore: 🎨 prettier

* docs: 📝  prettier

* docs: 📝 data-flow 更新

* docs: 📝 调整 i18n 文档

* refactor: 🔥 remove extra space

Co-authored-by: pshu <pishu.spf@antfin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants