UNPKG

1.99 kBMarkdownView Raw
1# 使用
2
3安装
4
5```shell script
6yarn add @gm-react-app/scripts
7```
8
9迁移指引
10
11```shell script
12gras migrate
13```
14
15之后跟着指引做就对了
16
17# 说明
18
19## 文件夹
20
21```
22my-project
23 build/
24 config/
25 deploy.js
26 local.js
27 webpack.config.js
28 src/
29 index.js
30 index.html
31 svg/
32 xxx.svg
33 .eslintrc.js
34 .gitignore
35 .prettierrc.js
36 .stylelintrc
37 babel.config.js
38 package.json
39 yarn.lock
40```
41
42/build 构建产物
43
44配置 /config/deploy.js /config/local.js
45
46```javascript
47module.exports = {
48 // 生产必填,开发默认 '/build/'
49 publicPath: '//js.guanmai.cn/build/xxxx/',
50 // 默认 8080
51 port: 8080,
52 // 默认不启用
53 https: false,
54 // 代理
55 proxy: [
56 {
57 context: ['/xxxx', '/xxx'],
58 target: 'url',
59 changeOrigin: true,
60 },
61 ],
62}
63```
64
65/config/webpack.config.js 如果修改 webpack 配置,提供此文件
66
67入口 /src/index.js
68
69模板 /src/index.html,支持 ejs 语法
70
71svg [svgr](https://github.com/gregberge/svgr) 只局限在 /svg 下,避免和其他 svg 冲突
72
73## babel
74
75默认值解析 src/目录下和 node_modules/下的 gm-、@gmfe、@gm-touch,其他请联系作者 or 自行补充
76
77## css
78
79less
80
81style-jsx
82
83## 其他
84
85react-hot-loader
86
87默认做了 alias
88
89```
90 alias: {
91 // yarn link 后保持 react 一致
92 react: path.resolve('react'),
93 common: PATH.appDirectory + 'src/js/common/',
94 stores: PATH.appDirectory + 'src/js/stores/',
95 svg: PATH.appDirectory + 'src/svg/',
96 img: PATH.appDirectory + 'src/img/'
97 }
98```
99
100环境
101
102```
103process.env.NODE_ENV development test production
104process.env.GIT_BRANCH
105process.env.GIT_COMMIT
106```
107
108变量
109
110```
111__DEBUG__
112__DEVELOPMENT__
113__TEST__
114__PRODUCTION__
115__VERSION__ 来自 package.json version
116__NAME__ 来自 package.json aliasName
117__CLIENT_NAME__ 来自 package.json clientName
118__BRANCH__
119__COMMIT__
120```
121
122模板变量
123
124```
125htmlWebpackPlugin.options.branch
126htmlWebpackPlugin.options.commit
127htmlWebpackPlugin.options.env
128```