(十八) ReactNative 发布线上时打包详解

来源:互联网 发布:js includes 编辑:程序博客网 时间:2024/05/20 04:10

使用Reactnative   进行 bundle的打包 

 一. 使用 curl  liunx/unix 命令  进行bundle  打包  (不能对图片资源等进行打包,)

 1). curl    url :拉去网页上对应的数据  

如发现乱码,可以使用iconv转码:

iconv的用法请参阅:在Linux/Unix系统下用iconv命令处理文本文件中文乱码问题

 2). Linux curl使用代理:

  linux curl使用http代理抓取页面:

使用socks代理抓取页面:

代理服务器地址可以从爬虫代理上获取。

3).linux curl处理cookies

接收cookies: 

发送cookies:

4). linux curl发送数据:

linux curl get方式提交数据: 

linux curl post方式提交数据:

以表单的方式上传文件: 

相当于设置form表单的method="POST"和enctype='multipart/form-data'两个属性。

5). linux curl http header处理:

设置http请求头信息:

设置http响应头处理:

6). linux curl认证: 
6). 其他 

二 .使用reactNative  自动的命令进行打包

打包时必须处于node_modules 的目录下

react-native  -h  

58deMacBook-Pro:react a58$ react-native -h

Command `-h` unrecognized

Usage: react-native <command>


Commands:

  - start: starts the web server     : 使用react-native start  启动本地的web server     在手动集成react-native时用到 

  - bundle: builds the javascript bundle for offline use: react-native bundle   来打包生成离线的bundle 包和assets包

58deMacBook-Pro:react a58$ react-native bundle

Options:

  --entry-file        Path to the root JS file, either absolute or relative to JS root                                   [required]

  --platform          Either "ios" or "android"                                                                        

  --transformer       Specify a custom transformer to be used (absolute path)                                            [default: "/Users/a58/Desktop/fouthDev/QianGuiAppReact_Pod/QianGuiApp/react/node_modules/react-native/packager/transformer.js"]

  --dev               If false, warnings are disabled and the bundle is minified                                         [default: true]

  --prepack           If true, the output bundle will use the Prepack format.                                            [default: false]

  --bridge-config     File name of a a JSON export of __fbBatchedBridgeConfig. Used by Prepack. Ex. ./bridgeconfig.json

  --bundle-output     File name where to store the resulting bundle, ex. /tmp/groups.bundle                              [required]

  --bundle-encoding   Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).       [default: "utf8"]

  --sourcemap-output  File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map            

  --assets-dest       Directory name where to store assets referenced in the bundle                                    

  --verbose           Enables logging                                                                                    [default: false]


Missing required arguments: entry-file, bundle-output

58deMacBook-Pro:react a58$ 


#

react-native bundle --entry-file  [index.ios.js /index.anroid.js的路径]  --bundle-output [打包完成后输出bundle 存放的目录] --platform [ios/android打包的平台]   --assets-dest [打包生成assets 时存放的目录]  --dev  false   

特别注意:--assets-dest 会搜索整个bundle中所引用到的图片资源,并进行打包生成assets 图片库供bundle  包进行使用

--entry-file: js文件的路径,既可以是绝对路经和相对路径

--paltform  :  打包对应的平台  //  ios   android 

--dev       :   开发还是发布   false 为发布,会对bundle 包进行压缩

--bundle-output:  生成bundle 的存放路径 

--assets-dest  : 生成assets  资源对应的存放路径

react-native bundle --entry-file ./index.ios.js --bundle-output ../index.ios.jsbundle  --platform ios --assets-dest ../  --dev false


  - unbundle: builds javascript as "unbundle" for offline use    // 将

  - new-library: generates a native library bridge

  - link: Adds a third-party library to your project. Example: react-native link awesome-camera

  - android: generates an Android project for your app

  - run-android: builds your app and starts it on a connected Android emulator or device

  - run-ios: builds your app and starts it on iOS simulator

  - upgrade: upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install



0 0
原创粉丝点击