2
2
3
3
[ umi] ( https://umijs.org/ ) preset plugins for react-native.
4
4
5
- > 👷 正在施工...
6
-
7
- - [x] umi-preset-react-native:react-native 插件集,** 必需** ;
8
- - [x] umi-plugin-react-native-bundler-haul:第三方 [ haul] ( https://github.com/callstack/haul ) 打包器,与 metro 只能** 二选一** 。
9
- - [ ] umi-plugin-react-native-bundler-metro:RN 官方 [ metro] ( https://facebook.github.io/metro/ ) 打包器,与 haul 只能** 二选一** ;
10
-
11
5
## 目录
12
6
13
7
- [ 必备] ( #%E5%BF%85%E5%A4%87 )
14
8
- [ 安装] ( #%E5%AE%89%E8%A3%85 )
15
- - [ 安装 react-native 预设插件集] ( #%E5%AE%89%E8%A3%85-react-native-%E9%A2%84%E8%AE%BE%E6%8F%92%E4%BB%B6%E9%9B%86 )
16
- - [ 安装 react-native 打包器] ( #%E5%AE%89%E8%A3%85-react-native-%E6%89%93%E5%8C%85%E5%99%A8 )
17
- - [ 选用官方 metro 打包] ( #%E9%80%89%E7%94%A8%E5%AE%98%E6%96%B9-metro-%E6%89%93%E5%8C%85 )
18
- - [ 选用第三方 haul 打包] ( #%E9%80%89%E7%94%A8%E7%AC%AC%E4%B8%89%E6%96%B9-haul-%E6%89%93%E5%8C%85 )
19
9
- [ 使用] ( #%E4%BD%BF%E7%94%A8 )
20
10
- [ 配置 umi] ( #%E9%85%8D%E7%BD%AE-umi )
21
11
- [ 开发] ( #%E5%BC%80%E5%8F%91 )
28
18
29
19
## 安装
30
20
31
- ### 安装 react-native 预设插件集
32
-
33
21
在 RN 工程内部安装:
34
22
35
23
``` npm
36
24
yarn add umi-preset-react-native --dev
37
25
```
38
26
39
- ### 安装 react-native 打包器
40
-
41
- ** 二选一,同时安装会导致 umi 报错(` dev ` 和` build ` 命令行工具冲突)。**
42
-
43
- #### 选用官方 metro 打包
44
-
45
- 在 RN 工程内部安装:
46
-
47
- ``` npm
48
- yarn add umi-plugin-react-native-bundler-metro --dev
49
- ```
50
-
51
- ** 注意:**
52
-
53
- ``` json
54
- {
55
- "name" : " umi-plugin-react-native-bundler-metro" ,
56
- "engines" : {
57
- "node" : " >=8.3"
58
- },
59
- "peerDependencies" : {
60
- "metro" : " ^0.58.0" ,
61
- "react" : " ^16.11.0" ,
62
- "react-native" : " >=0.62.0-rc.0 <1.0.x"
63
- }
64
- }
65
- ```
66
-
67
- #### 选用第三方 haul 打包
68
-
69
- 在 RN 工程内部安装:
70
-
71
- ``` npm
72
- yarn add umi-plugin-react-native-bundler-haul --dev
73
- ```
74
-
75
- ** 注意:**
27
+ ** 注意:** 以下是` umi-preset-react-native ` 对 Node、react、react-native、umi 版本的要求:
76
28
77
29
``` json
78
30
{
79
- "name" : " umi-plugin -react-native-bundler-haul " ,
31
+ "name" : " umi-preset -react-native" ,
80
32
"engines" : {
81
33
"node" : " >=10.x"
82
34
},
83
35
"peerDependencies" : {
84
36
"react" : " ^16.8.3" ,
85
- "react-native" : " >=0.59.0 <1.0.x"
37
+ "react-native" : " >=0.59.0 <1.0.x" ,
38
+ "umi" : " ^3.0.0"
86
39
}
87
40
}
88
41
```
@@ -97,16 +50,12 @@ export default {
97
50
history: {
98
51
type: ' memory' ,
99
52
},
100
- // dynamicImport: {
101
- // loading: 'components/MyLoading.js'
102
- // },
103
53
};
104
54
```
105
55
106
56
** 注意:**
107
57
108
58
- ` history ` 配置项:在 RN 中只能使用:` 'memory' ` 类型,[ umi] ( https://umijs.org/ ) 默认值是:` 'browser' ` 。` 'browser' ` 和` 'hash' ` 类型都需要 DOM,在 RN 中会报错;
109
- - ` dynamicImport ` 配置项:如果打算启用该功能,则必须实现一个自定义的 Loading 组件,且将组件的** 相对路径** 配置到这里覆盖默认值,[ umi] ( https://umijs.org/ ) 默认 loading 使用了 HTML 的` <p></p> ` 标签,在 RN 中会报错。
110
59
111
60
** 在 RN 中集成其他[ umi] ( https://umijs.org/ ) 插件需要开发者自行斟酌。**
112
61
0 commit comments