Minify both before and after browserify

This commit is contained in:
Ben Alpert
2013-12-28 23:41:54 -07:00
parent f877c6224f
commit abee8b0476
2 changed files with 33 additions and 18 deletions

View File

@@ -5,6 +5,7 @@
var envify = require('envify/custom');
var grunt = require('grunt');
var through = require('through');
var UglifyJS = require('uglify-js');
var SIMPLE_TEMPLATE =
@@ -32,7 +33,20 @@ var LICENSE_TEMPLATE =
*/';
function minify(src) {
return UglifyJS.minify(src, { fromString: true }).code;
return UglifyJS.minify(src, {
fromString: true,
mangle: {toplevel: true}
}).code;
}
function minifyTransform(file) {
var src = '';
return through(function write(buf) {
src += buf;
}, function end() {
this.queue(minify(src));
this.queue(null);
});
}
// TODO: move this out to another build step maybe.
@@ -67,7 +81,7 @@ var basic = {
var min = grunt.util._.merge({}, basic, {
outfile: './build/react.min.js',
debug: false,
transforms: [envify({NODE_ENV: 'production'})],
transforms: [envify({NODE_ENV: 'production'}), minifyTransform],
after: [minify, bannerify]
});
@@ -96,7 +110,7 @@ var addons = {
var addonsMin = grunt.util._.merge({}, addons, {
outfile: './build/react-with-addons.min.js',
debug: false,
transforms: [envify({NODE_ENV: 'production'})],
transforms: [envify({NODE_ENV: 'production'}), minifyTransform],
after: [minify, bannerify]
});

View File

@@ -39,29 +39,30 @@
},
"devDependencies": {
"browserify": "~2.36.1",
"coverify": "~0.1.1",
"envify": "~1.0.1",
"populist": "~0.1.6",
"grunt-cli": "~0.1.9",
"es5-shim": "~2.1.0",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.9",
"grunt-compare-size": "~0.4.0",
"grunt-complexity": "~0.1.3",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-compress": "~0.5.1",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-jshint": "~0.7.2",
"gzip-js": "~0.3.2",
"jasmine-tapreporter": "~0.2.2",
"optimist": "~0.6.0",
"phantomjs": "~1.9",
"populist": "~0.1.6",
"recast": "~0.5.6",
"semver": "~2.2.1",
"uglify-js": "~2.4.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-compare-size": "~0.4.0",
"gzip-js": "~0.3.2",
"tmp": "~0.0.18",
"grunt-contrib-compress": "~0.5.1",
"jasmine-tapreporter": "~0.2.2",
"grunt-contrib-connect": "~0.5.0",
"es5-shim": "~2.1.0",
"wd": "~0.2.6",
"sauce-tunnel": "~1.1.0",
"coverify": "~0.1.1",
"grunt-complexity": "~0.1.3"
"semver": "~2.2.1",
"through": "~2.3.4",
"tmp": "~0.0.18",
"uglify-js": "~2.4.0",
"wd": "~0.2.6"
},
"engines": {
"node": ">=0.10.0"