mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Update build scripts.
This commit is contained in:
23
lib/common/minify.js
Normal file
23
lib/common/minify.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs-extra'),
|
||||
uglify = require('uglify-js');
|
||||
|
||||
var uglifyOptions = require('./uglify.options.js');
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function minify(inpath, outpath, callback, options) {
|
||||
if (typeof outpath == 'function') {
|
||||
outpath = undefined;
|
||||
callback = options;
|
||||
}
|
||||
if (!outpath) {
|
||||
outpath = inpath.replace(/(?=\.js$)/, '.min');
|
||||
}
|
||||
var output = uglify.minify(inpath, _.defaults(options, uglifyOptions));
|
||||
fs.writeFile(outpath, output.code, 'utf-8', callback);
|
||||
}
|
||||
|
||||
module.exports = minify;
|
||||
16
lib/common/uglify.options.js
Normal file
16
lib/common/uglify.options.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'mangle': true,
|
||||
'compress': {
|
||||
'comparisons': false,
|
||||
'keep_fargs': true,
|
||||
'pure_getters': true,
|
||||
'unsafe': true,
|
||||
'unsafe_comps': true,
|
||||
'warnings': false
|
||||
},
|
||||
'output': {
|
||||
'ascii_only': true,
|
||||
'beautify': false,
|
||||
'max_line_len': 500
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user