@samitouri / QOS-React-2 / commits / abee8b0476

Minify both before and after browserify

Ben Alpert committed Dec 28, 2013 at 23:41 UTC abee8b04760fadefda53ed0aade2e76af642a6b7
2 files changed +32 -17
grunt/config/browserify.js
+17 -3
@@ -5,6 +5,7 @@
5
6 var envify = require('envify/custom');
7 var grunt = require('grunt');
8 +var through = require('through');
9 var UglifyJS = require('uglify-js');
10
11 var SIMPLE_TEMPLATE =
@@ -32,7 +33,20 @@ var LICENSE_TEMPLATE =
33 */';
34
35 function minify(src) {
35 - return UglifyJS.minify(src, { fromString: true }).code;
36 + return UglifyJS.minify(src, {
37 + fromString: true,
38 + mangle: {toplevel: true}
39 + }).code;
40 +}
41 +
42 +function minifyTransform(file) {
43 + var src = '';
44 + return through(function write(buf) {
45 + src += buf;
46 + }, function end() {
47 + this.queue(minify(src));
48 + this.queue(null);
49 + });
50 }
51
52 // TODO: move this out to another build step maybe.
@@ -67,7 +81,7 @@ var basic = {
81 var min = grunt.util._.merge({}, basic, {
82 outfile: './build/react.min.js',
83 debug: false,
70 - transforms: [envify({NODE_ENV: 'production'})],
84 + transforms: [envify({NODE_ENV: 'production'}), minifyTransform],
85 after: [minify, bannerify]
86 });
87
@@ -96,7 +110,7 @@ var addons = {
110 var addonsMin = grunt.util._.merge({}, addons, {
111 outfile: './build/react-with-addons.min.js',
112 debug: false,
99 - transforms: [envify({NODE_ENV: 'production'})],
113 + transforms: [envify({NODE_ENV: 'production'}), minifyTransform],
114 after: [minify, bannerify]
115 });
116
package.json
+15 -14
@@ -39,29 +39,30 @@
39 },
40 "devDependencies": {
41 "browserify": "~2.36.1",
42 + "coverify": "~0.1.1",
43 "envify": "~1.0.1",
43 - "populist": "~0.1.6",
44 - "grunt-cli": "~0.1.9",
44 + "es5-shim": "~2.1.0",
45 "grunt": "~0.4.1",
46 + "grunt-cli": "~0.1.9",
47 + "grunt-compare-size": "~0.4.0",
48 + "grunt-complexity": "~0.1.3",
49 + "grunt-contrib-clean": "~0.5.0",
50 + "grunt-contrib-compress": "~0.5.1",
51 + "grunt-contrib-connect": "~0.5.0",
52 "grunt-contrib-copy": "~0.4.1",
53 "grunt-contrib-jshint": "~0.7.2",
54 + "gzip-js": "~0.3.2",
55 + "jasmine-tapreporter": "~0.2.2",
56 "optimist": "~0.6.0",
57 "phantomjs": "~1.9",
58 + "populist": "~0.1.6",
59 "recast": "~0.5.6",
60 + "sauce-tunnel": "~1.1.0",
61 "semver": "~2.2.1",
52 - "uglify-js": "~2.4.0",
53 - "grunt-contrib-clean": "~0.5.0",
54 - "grunt-compare-size": "~0.4.0",
55 - "gzip-js": "~0.3.2",
62 + "through": "~2.3.4",
63 "tmp": "~0.0.18",
57 - "grunt-contrib-compress": "~0.5.1",
58 - "jasmine-tapreporter": "~0.2.2",
59 - "grunt-contrib-connect": "~0.5.0",
60 - "es5-shim": "~2.1.0",
61 - "wd": "~0.2.6",
62 - "sauce-tunnel": "~1.1.0",
63 - "coverify": "~0.1.1",
64 - "grunt-complexity": "~0.1.3"
64 + "uglify-js": "~2.4.0",
65 + "wd": "~0.2.6"
66 },
67 "engines": {
68 "node": ">=0.10.0"