UNPKG

4.31 kBMarkdownView Raw
1# {{name}}
2
3[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/) [![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg?style=flat-square)](https://github.com/conventional-changelog/standard-version)
4
5_新芽網路前端開發架構_
6
7## 簡介
8
9經由 `react-starter` 快速產生的專案,內建 `react` 開發用環境。
10
11## 資源介紹
12
13使用 `webpack` 做建置工具,專案架構使用 `universal-router``redux`,搭配 `eslint``react-storybook``jest` 開發,支援 `ES6``stage-3` 語法。
14
15## 如何開始
16
17- 安裝 nodejs v8 以上的版本
18- 安裝套件: `npm i` or `yarn`
19
20#### 踏出第一步
21
22啟動開發 server
23
24```
25npm start
26```
27
28便可在 <http://localhost:3000> 看到本地伺服器~
29
30啟動 storybook server
31
32```
33npm run storybook
34```
35
36便可在 <http://localhost:8000> 看到 storybook 開發伺服器~
37
38#### npm script
39
40- **npm start**: 啟動開發 server
41- **npm run dev**: 跟 `npm start` 一樣
42- **npm run demo**: 使用 `demo` 參數打包專案,部署在測試機。
43- **npm run build**: 使用 `production` 參數打包專案,部署在正式機。
44- **npm run lint**: 跑 eslint 跟 stylelint 檢查 coding style
45- **npm run storybook**: 跑 storybook
46- **npm test**: 跑 jest 測試
47
48## 專案架構
49
50此架構是參考 [Atom design](http://bradfrost.com/blog/post/atomic-web-design/) 和 [Fractal Project Structure](https://github.com/davezuko/react-redux-starter-kit/wiki/Fractal-Project-Structure) 所整理出來
51
52> 註: atom design 裡的 Template 是這裡的 Layout,而 Page 則是在 routes 資料夾下
53
54以下是這個專案的各資料夾定義
55- src
56 + components
57 - **atom**: 原子 component ,不可再分割的基本 component, ex `button`, `label`, `html tag`
58 - **molecules**: 分子 component,由原子組成的基本 component, ex `地址輸入欄位` (包含 `label`, `input`, `button` 等)
59 - **organisms**: 組織 component,由原子、分子組成的多功能 component, ex `header`, `footer`
60 + images
61 + **layouts**: 放置版型的地方,提供不同版型給許多頁面
62 - **models**: 存放 reducer 和 action 的地方
63 - **routes**: 定義每一頁的 routing 規則,底下每一個資料夾就是單獨一頁
64 - **store**: 設定 redux middlewares 的地方
65- **config**: 設定環境變數、調色盤、media query 範圍、endpoint 位置
66- **storybook**: 存放 storybook 的設定檔
67
68> 0.8.0 之後 component 的 stories 和 test case 移至各自的 component 資料夾裡面
69
70## 參數設定
71
72#### 環境變數
73
74以下是 `npm run dev`, `npm run build:demo`, `npm run build` 各自對應的環境變數
75
76| script | NODE_ENV | PROXY | API |
77| -------------- | ---------- | ---------- | ---------- |
78| dev:demo | devlopment | demo | dev |
79| dev:production | devlopment | production | dev |
80| build:demo | devlopment | | demo |
81| build | production | | production |
82
83#### CSS 標準色
84
85CSS 所用的全域變數,可以於 `config/palette.js` 設定整個網站的標準色等。
86
87```javascript
88export default {
89 standard: '#999',
90 secondary: '#DDD',
91 darkBlack: '#404040',
92};
93```
94
95#### CSS Media Query 設置
96
97CSS 所用的全域變數,可以於 `config/media.js` 設定整個網站的 media query。
98
99```javascript
100export default {
101 '--phone': '(width < 600px)',
102 '--small-tablet': '(900px > width >= 600px)',
103 '--tablet': '(1200px > width >= 900px)',
104 '--desktop': '(width >= 1200px)',
105};
106```
107
108## Contribution
109
110此專案 commit message 使用 angular format ,並使用 [commitizen](http://commitizen.github.io/cz-cli/) 輔助產生 commit message
111
112- 加入修改的檔案 `git add .`
113- 產生 commit message `npm run commit`
114
115## Release
116
117此專案使用 [standard-version](https://github.com/conventional-changelog/standard-version) 輔助 release 流程,自動產生 `CHANGELOG.md` 和 提升版本號(提升 major version 依據是否有 `feat` 來判斷)
118
119- `npm run release`
120
121可以自己決定 提升 patch, minor or major
122
123- `npm run release -- --release-as minor`
124
125**Warning**: 第一次 release 請下
126
127- `npm run release -- --first-release`