packager: optimize assets' JS
Reviewed By: davidaurelio Differential Revision: D5010186 fbshipit-source-id: 3c26d8b8792df1dbc24e5200f28f63e017cb0173
This commit is contained in:
parent
2a5959ae6e
commit
7d6fec0a39
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Copyright (c) 2016-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const UGLIFY_JS_OUTPUT_OPTIONS = {
|
||||
ascii_only: true,
|
||||
screw_ie8: true,
|
||||
};
|
||||
|
||||
module.exports = {UGLIFY_JS_OUTPUT_OPTIONS};
|
|
@ -13,15 +13,14 @@
|
|||
|
||||
const uglify = require('uglify-js');
|
||||
|
||||
const {UGLIFY_JS_OUTPUT_OPTIONS} = require('./JsMinification');
|
||||
|
||||
function minify(filename: string, code: string, sourceMap: ?string) {
|
||||
const minifyResult = uglify.minify(code, {
|
||||
fromString: true,
|
||||
inSourceMap: sourceMap,
|
||||
outSourceMap: true,
|
||||
output: {
|
||||
ascii_only: true,
|
||||
screw_ie8: true,
|
||||
},
|
||||
output: UGLIFY_JS_OUTPUT_OPTIONS,
|
||||
});
|
||||
|
||||
minifyResult.map = JSON.parse(minifyResult.map);
|
||||
|
|
|
@ -152,6 +152,7 @@ export type TransformedSourceFile =
|
|||
|
||||
export type LibraryOptions = {|
|
||||
dependencies?: Array<string>,
|
||||
optimize: boolean,
|
||||
platform?: string,
|
||||
rebasePath: string => string,
|
||||
|};
|
||||
|
|
Loading…
Reference in New Issue