mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Update build scripts.
This commit is contained in:
@@ -2,19 +2,21 @@
|
||||
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
fs = require('fs'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path'),
|
||||
uglify = require('uglify-js'),
|
||||
webpack = require('webpack');
|
||||
|
||||
var entryPath = path.join(__dirname, 'bower.js'),
|
||||
outputPath = path.join(__dirname, '..', '..', 'dist'),
|
||||
var minify = require('../common/minify.js');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
distPath = path.join(basePath, 'dist'),
|
||||
entryPath = path.join(__dirname, 'bower.js'),
|
||||
filename = 'lodash.fp.js';
|
||||
|
||||
var webpackConfig = {
|
||||
'entry': entryPath,
|
||||
'output': {
|
||||
'path': outputPath,
|
||||
'path': distPath,
|
||||
'filename': filename,
|
||||
'library': 'fp',
|
||||
'libraryTarget': 'umd'
|
||||
@@ -23,34 +25,10 @@ var webpackConfig = {
|
||||
new webpack.optimize.OccurenceOrderPlugin,
|
||||
new webpack.optimize.DedupePlugin
|
||||
]
|
||||
}
|
||||
|
||||
var uglifyConfig = {
|
||||
'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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function minify(inputPath, callback) {
|
||||
var output = uglify.minify(inputPath, uglifyConfig),
|
||||
outputPath = inputPath.replace(/(?=\.js$)/, '.min');
|
||||
|
||||
fs.writeFile(outputPath, output.code, 'utf-8', callback);
|
||||
}
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
@@ -59,5 +37,5 @@ function onComplete(error) {
|
||||
|
||||
async.series([
|
||||
_.partial(webpack, webpackConfig),
|
||||
_.partial(minify, path.join(outputPath, filename))
|
||||
_.partial(minify, path.join(distPath, filename))
|
||||
], onComplete);
|
||||
|
||||
Reference in New Issue
Block a user