Update build scripts.

This commit is contained in:
John-David Dalton
2015-10-22 21:06:08 -07:00
parent 99287a89eb
commit ac16bc0e15
5 changed files with 77 additions and 31 deletions

View File

@@ -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);