You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
react-native bundle [options]
builds the javascript bundle for offline use
Options:
-h, --help output usage information
--entry-file <path> Path to the root JS file, either absolute or relative to JS root
--platform [string] Either "ios" or "android"
--transformer [string] Specify a custom transformer to be used
--dev [boolean] If false, warnings are disabled and the bundle is minified
--prepack When passed, the output bundle will use the Prepack format.
--bridge-config [string] File name of a a JSON export of __fbBatchedBridgeConfig. Used by Prepack. Ex. ./bridgeconfig.json
--bundle-output <string> File name where to store the resulting bundle, ex. /tmp/groups.bundle
--bundle-encoding [string] Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).
--sourcemap-output [string] File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map
--assets-dest [string] Directory name where to store assets referenced in the bundle
--verbose Enables logging
--reset-cache Removes cached files
--config [string] Path to the CLI configuration file
ReactNative - 打离线包 (一) 原生RN命令打包
离线包
离线包就是把 ReactNative 和你写的 js文件、图片等资源都打包放入 App ,不需要走网络下载。
ReactNative 打包命令说明
使用 react-native bundle --help 来查看打包的具体参数
以上为官方给出的解释,我们来对应的翻译下每条参数的含义。
看过了以上的翻译,基本对每条参数都有了一定的了解,我们来实际操作下打包的步骤。
ReactNative 打离线包流程 (举例iOS)
首先你得有个 ReactNative 的工程。这里以空工程打包为例:
1.创建新工程
2.执行打包命令
3.查看执行完打包命令后的结果
4.将 assets 和 index.ios.jsbundle 引入工程
5.修改AppDelegate中的代码
6.如果要真机测试或打包上传应用, 需要进行如下修改
因为 ReactNative 自带 Chrome 的 Debug 模式, 因此需要修改成 Release ,来关闭掉 Debug 模式
7.打包上传或真机调试,与iOS工程无异。
ReactNative 打离线包中注意事项
参考文章
https://segmentfault.com/a/1190000004189538
http://www.ruanyifeng.com/blog/2013/01/javascript_source_map.html
http://402v.com/react-nativeru-men-shi-li-jiao-cheng-xiang-mu-da-bao-fa-bu/
https://nodejs.org/api/buffer.html#buffer_buffer
http://reactnative.cn/docs/0.39/running-on-device-ios.html#content
文章预告
下篇文章我会进行携程 moles-packer 框架的分包过程及命令。欢迎大家继续关注 ReactNative - 打离线包 (二) 携程Moles-Packer框架命令打包。
The text was updated successfully, but these errors were encountered: