element/examples/docs/development.md

50 lines
1.2 KiB
Markdown
Raw Normal View History

2016-08-30 11:30:58 +00:00
## 开发指南
2016-09-19 08:17:32 +00:00
开发之前需要配置好 Node.js 和 npm 环境,其中 npm 需要 3.0 或以上版本。
2016-08-30 11:30:58 +00:00
2016-09-19 08:17:32 +00:00
### 目录结构
```text
|- examples/ -------------- 文档及示例页
|- docs/ -------------- 文档
|- component/
|- src/ --------------- 组件源码
|- packages/ -------------- 组件
|- scripts/ --------------- 打包配置
|- src/ ------------------- 公用代码
|- components.json -------- 组件列表
```
2016-08-30 11:30:58 +00:00
2016-09-19 08:17:32 +00:00
### 安装依赖
安装项目所需要的依赖以及子项目内的依赖。
2016-08-30 11:30:58 +00:00
```bash
2016-09-19 08:17:32 +00:00
npm run bootstrap
```
如果网络不是很理想,可以用国内镜像下载。新建一个 `.npmrc` 文件在当前项目下,同时配置镜像地址,例如:
```text
registry=https://registry.npm.taobao.org
2016-08-30 11:30:58 +00:00
```
2016-09-19 08:17:32 +00:00
然后再运行 `npm run bootstrap` 安装依赖。
### 启动开发环境
启动完成后浏览器访问 [http://localhost:8085](http://localhost:8085)
2016-08-30 11:30:58 +00:00
```bash
2016-09-19 08:17:32 +00:00
npm run dev
2016-08-30 11:30:58 +00:00
```
2016-09-19 08:17:32 +00:00
### npm scripts
```bash
npm run dev # 启动开发环境
npm run dist # 打包组件
npm run dist:all # 单独打包每个子项目
npm run lint # 检测 js 代码风格
node bin/new.js [组件名] # 创建新组件
```
### 贡献代码
参考 [贡献者文档](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.md)。