mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +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
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2,19 +2,21 @@
|
|||||||
|
|
||||||
var _ = require('lodash'),
|
var _ = require('lodash'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
fs = require('fs'),
|
fs = require('fs-extra'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
uglify = require('uglify-js'),
|
|
||||||
webpack = require('webpack');
|
webpack = require('webpack');
|
||||||
|
|
||||||
var entryPath = path.join(__dirname, 'bower.js'),
|
var minify = require('../common/minify.js');
|
||||||
outputPath = path.join(__dirname, '..', '..', 'dist'),
|
|
||||||
|
var basePath = path.join(__dirname, '..', '..'),
|
||||||
|
distPath = path.join(basePath, 'dist'),
|
||||||
|
entryPath = path.join(__dirname, 'bower.js'),
|
||||||
filename = 'lodash.fp.js';
|
filename = 'lodash.fp.js';
|
||||||
|
|
||||||
var webpackConfig = {
|
var webpackConfig = {
|
||||||
'entry': entryPath,
|
'entry': entryPath,
|
||||||
'output': {
|
'output': {
|
||||||
'path': outputPath,
|
'path': distPath,
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'library': 'fp',
|
'library': 'fp',
|
||||||
'libraryTarget': 'umd'
|
'libraryTarget': 'umd'
|
||||||
@@ -23,34 +25,10 @@ var webpackConfig = {
|
|||||||
new webpack.optimize.OccurenceOrderPlugin,
|
new webpack.optimize.OccurenceOrderPlugin,
|
||||||
new webpack.optimize.DedupePlugin
|
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) {
|
function onComplete(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw error;
|
throw error;
|
||||||
@@ -59,5 +37,5 @@ function onComplete(error) {
|
|||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
_.partial(webpack, webpackConfig),
|
_.partial(webpack, webpackConfig),
|
||||||
_.partial(minify, path.join(outputPath, filename))
|
_.partial(minify, path.join(distPath, filename))
|
||||||
], onComplete);
|
], onComplete);
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
'use strict';
|
'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);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"docdown": "0.3.0",
|
"docdown": "0.3.0",
|
||||||
"dojo": "~1.10.0",
|
"dojo": "~1.10.0",
|
||||||
"ecstatic": "^1.1.3",
|
"ecstatic": "^1.1.3",
|
||||||
|
"fs-extra": "~0.24.0",
|
||||||
"istanbul": "0.4.0",
|
"istanbul": "0.4.0",
|
||||||
"jquery": "~1.11.0",
|
"jquery": "~1.11.0",
|
||||||
"jscs": "^2.3.5",
|
"jscs": "^2.3.5",
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
"webpack": "^1.12.2"
|
"webpack": "^1.12.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build": "node lib/main/build.js && node lib/fp/build.js",
|
||||||
"style": "jscs lodash.js",
|
"style": "jscs lodash.js",
|
||||||
"test": "node test/test"
|
"test": "node test/test"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user