Permalink
Browse files

doc: migrate Practical Projects to roadhog@2

  • Loading branch information...
sorrycc authored and afc163 committed Jan 7, 2018
1 parent c8c8044 commit 5dcf1c015fc2674adb09434bf766549d6f3f0022
Showing with 16 additions and 20 deletions.
  1. +8 −10 docs/react/practical-projects.en-US.md
  2. +8 −10 docs/react/practical-projects.zh-CN.md
@@ -13,12 +13,12 @@ Include the following:
## Install dva-cli
Install dva-cli with npm, and make sure the version is later than `0.8.1`.
Install dva-cli with npm, and make sure the version is later than `0.9.1`.
```bash
$ npm install dva-cli -g
$ dva -v
0.8.1
dva-cli version 0.9.1
```
## Create New App
@@ -61,17 +61,15 @@ Install `antd` and `babel-plugin-import` with npm. `babel-plugin-import` is used
$ npm install antd babel-plugin-import --save
```
Edit `.roadhogrc` to integrate `babel-plugin-import`.
Edit `.webpackrc` to integrate `babel-plugin-import`.
```diff
"extraBabelPlugins": [
- "transform-runtime"
+ "transform-runtime",
+ "extraBabelPlugins": [
+ ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }]
],
+ ],
```
> Notice: dva-cli's build and server is based on roadhog, view [roadhog#Configuration](https://github.com/sorrycc/roadhog/blob/master/README_en-us.md#configuration) for more `.roadhogrc` Configuration.
> Notice: dva-cli's build and dev is based on roadhog, view [roadhog#Configuration](https://github.com/sorrycc/roadhog/blob/master/README_en-us.md#configuration) for more `.roadhogrc` Configuration.
## Define Router
@@ -174,7 +172,7 @@ Then don't forget to require it in `index.js`:
```diff
// 3. Model
+ app.model(require('./models/products'));
+ app.model(require('./models/products').default);
```
## Connect
@@ -275,4 +273,4 @@ You can:
- Know all [dva APIs](https://github.com/dvajs/dva/blob/master/docs/API.md)
- Checkout [dva knowledgemap](https://github.com/dvajs/dva-knowledgemap), including all the basic knowledge with ES6, React, dva
- Checkout [more FAQ](https://github.com/dvajs/dva/issues?q=is%3Aissue+is%3Aclosed+label%3Afaq)
- If your project is created with [dva-cli](https://github.com/dvajs/dva-cli) , checkout how to [Configure it](https://github.com/sorrycc/roadhog#配置)
- If your project is created with [dva-cli](https://github.com/dvajs/dva-cli) , checkout how to [Configure it](https://github.com/sorrycc/roadhog#configuration)
@@ -15,12 +15,12 @@ title: 项目实战
## 安装 dva-cli
通过 npm 安装 dva-cli 并确保版本是 `0.8.1` 或以上。
通过 npm 安装 dva-cli 并确保版本是 `0.9.1` 或以上。
```bash
$ npm install dva-cli -g
$ dva -v
0.8.2
dva-cli version 0.9.1
```
## 创建新应用
@@ -63,17 +63,15 @@ To create a production build, use npm run build.
$ npm install antd babel-plugin-import --save
```
编辑 `.roadhogrc`,使 `babel-plugin-import` 插件生效。
编辑 `.webpackrc`,使 `babel-plugin-import` 插件生效。
```diff
"extraBabelPlugins": [
- "transform-runtime"
+ "transform-runtime",
+ "extraBabelPlugins": [
+ ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }]
],
+ ],
```
> 注:dva-cli 基于 roadhog 实现 build 和 server,更多 `.roadhogrc` 的配置详见 [roadhog#配置](https://github.com/sorrycc/roadhog#配置)
> 注:dva-cli 基于 roadhog 实现 build 和 dev,更多 `.roadhogrc` 的配置详见 [roadhog#配置](https://github.com/sorrycc/roadhog#配置)
## 定义路由
@@ -176,7 +174,7 @@ export default {
```diff
// 3. Model
+ app.model(require('./models/products'));
+ app.model(require('./models/products').default);
```
## connect 起来
@@ -277,4 +275,4 @@ File sizes after gzip:
- 掌握 dva 的[所有 API](https://github.com/dvajs/dva/blob/master/docs/API_zh-CN.md)
- 查看 [dva 知识地图](https://github.com/dvajs/dva-knowledgemap) ,包含 ES6, React, dva 等所有基础知识
- 查看 [更多 FAQ](https://github.com/dvajs/dva/issues?q=is%3Aissue+is%3Aclosed+label%3Afaq),看看别人通常会遇到什么问题
- 如果你基于 dva-cli 创建项目,最好了解他的 [配置方式](https://github.com/sorrycc/roadhog#配置)
- 如果你基于 dva-cli 创建项目,最好了解他的 [配置方式](https://github.com/sorrycc/roadhog/blob/master/README_zh-cn.md#配置)

0 comments on commit 5dcf1c0

Please sign in to comment.