-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bundle command using ReactPackager
Added bundle script Pipe http response straight to file Used ReactPackager directly, minor fixes
- Loading branch information
1 parent
d937071
commit ef209c1
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var http = require('http'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var blacklist = require('../packager/blacklist.js'); | ||
var ReactPackager = require('../packager/react-packager'); | ||
|
||
var OUT_PATH = 'iOS/main.jsbundle'; | ||
|
||
function getBundle(flags) { | ||
|
||
var options = { | ||
projectRoots: [path.resolve(__dirname, '../../..')], | ||
transformModulePath: require.resolve('../packager/transformer.js'), | ||
assetRoots: [path.resolve(__dirname, '../../..')], | ||
cacheVersion: '2', | ||
blacklistRE: blacklist('ios') | ||
}; | ||
|
||
var url = '/index.ios.bundle?dev=' + flags.dev; | ||
|
||
console.log('Building package...'); | ||
ReactPackager.buildPackageFromUrl(options, url) | ||
.then(function(bundle) { | ||
console.log('Build complete'); | ||
fs.writeFile(OUT_PATH, bundle.getSource({ | ||
inlineSourceMap: false, | ||
minify: flags.minify | ||
}), function() { | ||
console.log('Successfully saved bundle to ' + OUT_PATH); | ||
}); | ||
}); | ||
} | ||
|
||
function showHelp() { | ||
console.log([ | ||
'Usage: react-native bundle [options]', | ||
'', | ||
'Options:', | ||
' --dev\t\tsets DEV flag to true', | ||
' --minify\tminify js bundle' | ||
].join('\n')); | ||
process.exit(1); | ||
} | ||
|
||
module.exports = { | ||
init: function(args) { | ||
var flags = { | ||
help: args.indexOf('--help') !== -1, | ||
dev: args.indexOf('--dev') !== -1, | ||
minify: args.indexOf('--minify') !== -1 | ||
} | ||
|
||
if (flags.help) { | ||
showHelp(); | ||
} else { | ||
getBundle(flags); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters