Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
doc: migrate Practical Projects to roadhog@2
Loading branch information
@@ -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 #配置)
Toggle all file notes