Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions local-cli/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ var URL_PATH = {
android: '/index.android.bundle?platform=android&dev=',
ios: '/index.ios.bundle?platform=ios&dev='
};
var SOURCEMAP_OUT_PATH = {
android: 'android/index.android.map',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be android/app/src/main/assets/index.android.map?

ios: 'ios/index.ios.map'
};

function getBundle(flags) {
var platform = flags.platform ? flags.platform : 'ios';
var outPath = flags.out ? flags.out : OUT_PATH[platform];
var sourceMapOutPath = SOURCEMAP_OUT_PATH[platform];

var projectRoots = [path.resolve(__dirname, '../../..')];
if (flags.root) {
Expand Down Expand Up @@ -50,12 +55,23 @@ function getBundle(flags) {
fs.writeFile(outPath, bundle.getSource({
inlineSourceMap: false,
minify: flags.minify
}), function(err) {
if (err) {
}), function(bundleWriteErr) {
if (bundleWriteErr) {
console.log(chalk.red('Error saving bundle to disk'));
throw err;
} else {
console.log('Successfully saved bundle to ' + outPath);
throw bundleWriteErr;
}

console.log('Successfully saved bundle to ' + outPath);

if (flags.writeSourcemap) {
fs.writeFile(sourceMapOutPath, bundle.getSourceMap(), function(sourceMapWriteErr) {
if (sourceMapWriteErr) {
console.log(chalk.red('Error saving source map to disk'));
throw sourceMapWriteErr;
} else {
console.log('Successfully saved source map to ' + sourceMapOutPath);
}
});
}
});
});
Expand All @@ -73,6 +89,7 @@ function showHelp() {
' --out\t\tspecify the output file',
' --url\t\tspecify the bundle file url',
' --platform\t\tspecify the platform(android/ios)',
' --write-sourcemap\t\twrite bundle source map to disk'
].join('\n'));
process.exit(1);
}
Expand All @@ -88,6 +105,7 @@ module.exports = {
assetRoots: args.indexOf('--assetRoots') !== -1 ? args[args.indexOf('--assetRoots') + 1] : false,
out: args.indexOf('--out') !== -1 ? args[args.indexOf('--out') + 1] : false,
url: args.indexOf('--url') !== -1 ? args[args.indexOf('--url') + 1] : false,
writeSourcemap: args.indexOf('--write-sourcemap') !== -1,
}

if (flags.help) {
Expand Down