Skip to content

Commit

Permalink
doc: migrate Practical Projects to roadhog@2
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc authored and afc163 committed Jan 8, 2018
1 parent c8c8044 commit 5dcf1c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
18 changes: 8 additions & 10 deletions docs/react/practical-projects.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
18 changes: 8 additions & 10 deletions docs/react/practical-projects.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

## 创建新应用
Expand Down Expand Up @@ -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#配置)
## 定义路由

Expand Down Expand Up @@ -176,7 +174,7 @@ export default {

```diff
// 3. Model
+ app.model(require('./models/products'));
+ app.model(require('./models/products').default);
```

## connect 起来
Expand Down Expand Up @@ -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.