8000 feat: support some PWA features by xiaoiver · Pull Request #1307 · umijs/umi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: support some PWA features #1307

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

Merged
merged 4 commits into from
Oct 25, 2018
Merged

feat: support some PWA features #1307

merged 4 commits into from
Oct 25, 2018

Conversation

xiaoiver
Copy link
Contributor
@xiaoiver xiaoiver commented Oct 23, 2018

大致包含以下:

  1. 根据用户配置生成 Web App Manifest,主要是为一些属性拼接上 publicPath。默认读取 src/manifest.json,如果用户未提供则根据项目名生成一个简单的
  2. 使用 PWACompat 根据 Web App Manifest 和运行时浏览器环境生成一些兼容性的 <meta> 标签
  3. 默认使用 GenerateSW 模式,如果配置了 InjectManifest 模式,默认将 src/service-worker.js 作为源文件传给 Workbox
  4. Service Worker 发生更新时触发 CustomEvent,相关组件(例如显示更新提示的小弹窗)可以监听 sw.updated,引导用户手动刷新页面
  5. 相关测试和文档修改

基本的配置如下:

pwa: {
    manifestOptions: {
      // 默认值为 'src/manifest.json'
      srcPath: 'path/to/manifest.webmanifest')
    },
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      importWorkboxFrom: 'local',
      // 默认值为 'src/service-worker.js'
      swSrc: 'path/to/service-worker.js')
    }
  }

@coveralls
Copy link
coveralls commented Oct 23, 2018

Pull Request Test Coverage Report for Build 1750

  • 15 of 190 (7.89%) changed or added relevant lines in 6 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.5%) to 30.824%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/umi-build-dev/src/plugins/commands/build/index.js 0 1 0.0%
packages/umi-plugin-react/src/plugins/pwa/generateWebManifest.js 15 17 88.24%
packages/umi-plugin-react/src/plugins/pwa/registerServiceWorker.js 0 6 0.0%
packages/umi-plugin-react/src/plugins/pwa/index.js 0 8 0.0%
packages/umi-plugin-react/src/plugins/pwa/WebManifestPlugin.js 0 21 0.0%
packages/umi-plugin-react/src/plugins/pwa/pwacompat.min.js 0 137 0.0%
Files with Coverage Reduction New Missed Lines %
packages/umi-plugin-react/src/plugins/pwa/index.js 3 0.0%
Totals Coverage Status
Change from base Build 1743: -1.5%
Covered Lines: 975
Relevant Lines: 3249

💛 - Coveralls

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.

3 participants
0