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

Todos #2

Open
2 of 4 tasks
Mesamo opened this issue Aug 17, 2017 · 6 comments
Open
2 of 4 tasks

Todos #2

Mesamo opened this issue Aug 17, 2017 · 6 comments
Assignees

Comments

@Mesamo
Copy link
Owner

Mesamo commented Aug 17, 2017

  • bundle提取公用模块
  • Testing Framework
  • Progressive Web App
  • more to do...
@Mesamo Mesamo changed the title TODO Todos Aug 18, 2017
@Mesamo Mesamo self-assigned this Aug 18, 2017
@Mesamo
Copy link
Owner Author

Mesamo commented Aug 23, 2017

bundle提取公用模块

  1. src目录添加vendor.js, 把一些公用的模块都引用下
import 'react'
import 'react-dom'
import 'react-router'
import 'core-js'
import 'rc-queue-anim';
import 'prop-types'
import 'path-to-regexp'
import 'dva'
import 'dva-loading'
import 'firebase/app'
import 'firebase/auth'
import 'firebase/database'

import antd from 'antd'

/* eslint-disable */
const { Table, Form, Layout, Row, Col, Menu, Dropdown, Popover, Input, Button, Checkbox,
  Card, Icon, Progress, Alert, Switch, Radio, Modal, message, notification
} = antd
/* eslint-disable */
  1. 修改.roadhogrc
{
- "entry": "./src/index.js",
+ "entry": {
+   "index": "./src/index.js",
+   "common": "./src/vendor.js"
+ },
+ "multipage": true,
    ....
    ....
}

@Mesamo
Copy link
Owner Author

Mesamo commented Aug 24, 2017

Progressive Web App

  1. 安装sw-precache
$ npm install sw-precache --save-dev
  1. 根目录添加sw-precache-config.js
+module.exports = {
+  stripPrefix: 'dist/',
+  staticFileGlobs: [
+    'dist/favicon.ico',
+    'dist/manifest.json',
+    'dist/index.html',
+    'dist/assets/**/*',
+    'dist/static/*',
+    'dist/*.js',
+    'dist/*.css'
+  ],
+  dontCacheBustUrlsMatching: /\.\w{8}\./,
+  swFilePath: 'dist/service-worker.js'
+};

将静态文件和不常变动的第三方模块加入cache storage

  1. 修改构建脚本
{
    ...
    "scripts": {
      "start": "roadhog server",
-     "build": "roadhog build",
+     "build": "roadhog build && sw-precache --config=sw-precache-config.js",
      "analyze": "roadhog build --analyze",
      "lint": "eslint --ext .js src test",
      "precommit": "npm run lint"
    }
    ...
}
  1. 修改index.ejs,注册service worker
<body>
  <div id="root">loading</div>
+ <script>
+    if ('serviceWorker' in navigator) {
+     navigator.serviceWorker.register('/service-worker.js');
+   }
+ </script>
</body>
  1. public目录下添加manifest.json
{
  "name": "Dva Admin -- Mesamo",
  "short_name": "Dva Admin",
  "display": "standalone",
  "start_url": "/",
  "theme_color": "#8fc9fb",
  "background_color": "#ffffff",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "400x400",
      "type": "image/png"
    }
  ]
}

Your First Progressive Web App

@LuciferLi
Copy link

不是npm install sw-pecache --save-dev,是npm install sw-percache --save-dev

@Mesamo
Copy link
Owner Author

Mesamo commented Sep 7, 2017

@LuciferLi 已修改,谢谢

@syaivin
Copy link

syaivin commented Mar 10, 2018

@Mesamo 没有测试账号密码吗?

@Mesamo
Copy link
Owner Author

Mesamo commented Mar 11, 2018

@syaivin 登录功能使用的是firebase的服务,可以直接注册(需要科学上网)。

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

No branches or pull requests

3 participants