2017-01-28 58 views

回答

2

當您創建生產JavaScript捆綁包時,DEV模式會自動關閉。通常,您不需要自己完成此任務,因爲打包程序在運行XCode存檔任務或Android部署時創建捆綁包。

但是,您可以使用react-native bundle --dev=false命令手動創建捆綁包,例如,

react-native bundle --dev=false --entry-file=index.ios.js --bundle-output=app.jsbundle --platform=ios 

bundle命令採用以下選項:

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 
    --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 
    --read-global-cache   Try to fetch transformed JS code from the global cache, if configured. 
    --config [string]   Path to the CLI configuration file