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

23
lib/common/minify.js Normal file
View 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;

View 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
}
};

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

View File

@@ -1 +1,28 @@
'use strict';
var _ = require('lodash'),
async = require('async'),
fs = require('fs-extra'),
path = require('path');
var minify = require('../common/minify.js');
var basePath = path.join(__dirname, '..', '..'),
distPath = path.join(basePath, 'dist'),
filename = 'lodash.js';
var baseLodash = path.join(basePath, filename),
distLodash = path.join(distPath, filename);
/*----------------------------------------------------------------------------*/
function onComplete(error) {
if (error) {
throw error;
}
}
async.series([
_.partial(fs.copy, baseLodash, distLodash),
_.partial(minify, distLodash)
], onComplete);

View File

@@ -11,6 +11,7 @@
"docdown": "0.3.0",
"dojo": "~1.10.0",
"ecstatic": "^1.1.3",
"fs-extra": "~0.24.0",
"istanbul": "0.4.0",
"jquery": "~1.11.0",
"jscs": "^2.3.5",
@@ -25,6 +26,7 @@
"webpack": "^1.12.2"
},
"scripts": {
"build": "node lib/main/build.js && node lib/fp/build.js",
"style": "jscs lodash.js",
"test": "node test/test"
},