Upgrade uglify and simplify usage
- Upgrade to the most recent version of uglify - Use the `UglifyJS.minify(code)` helper which does exactly what we want
This commit is contained in:
parent
ee03e7cd78
commit
318c5f7ba6
4 changed files with 25 additions and 13 deletions
22
package-lock.json
generated
22
package-lock.json
generated
|
@ -438,6 +438,11 @@
|
|||
"resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz",
|
||||
"integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto="
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
},
|
||||
"split": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz",
|
||||
|
@ -489,9 +494,20 @@
|
|||
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.3.3.tgz",
|
||||
"integrity": "sha1-3dPpiqJ/X0flic+z+VzduiYJYZA="
|
||||
"version": "3.1.6",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.6.tgz",
|
||||
"integrity": "sha512-/rseyxEKEVMBo8279lqpoJgD6C/i/CIi+9TJDvWmb+Xo6mqMKwjA8Io3IMHlcXQzj99feR6zrN8m3wqqvm/nYA==",
|
||||
"requires": {
|
||||
"commander": "2.11.0",
|
||||
"source-map": "0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"winston": "0.6.2",
|
||||
"redis-url": "0.1.0",
|
||||
"redis": "0.8.1",
|
||||
"uglify-js": "1.3.3",
|
||||
"uglify-js": "3.1.6",
|
||||
"busboy": "0.2.4",
|
||||
"pg": "4.1.1"
|
||||
},
|
||||
|
|
12
server.js
12
server.js
|
@ -1,6 +1,7 @@
|
|||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
|
||||
var uglify = require('uglify-js');
|
||||
var winston = require('winston');
|
||||
var connect = require('connect');
|
||||
var route = require('connect-route');
|
||||
|
@ -54,19 +55,14 @@ else {
|
|||
|
||||
// Compress the static javascript assets
|
||||
if (config.recompressStaticAssets) {
|
||||
var jsp = require('uglify-js').parser;
|
||||
var pro = require('uglify-js').uglify;
|
||||
var list = fs.readdirSync('./static');
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
var item = list[j];
|
||||
var orig_code, ast;
|
||||
if ((item.indexOf('.js') === item.length - 3) && (item.indexOf('.min.js') === -1)) {
|
||||
var dest = item.substring(0, item.length - 3) + '.min' + item.substring(item.length - 3);
|
||||
orig_code = fs.readFileSync('./static/' + item, 'utf8');
|
||||
ast = jsp.parse(orig_code);
|
||||
ast = pro.ast_mangle(ast);
|
||||
ast = pro.ast_squeeze(ast);
|
||||
fs.writeFileSync('./static/' + dest, pro.gen_code(ast), 'utf8');
|
||||
var orig_code = fs.readFileSync('./static/' + item, 'utf8');
|
||||
|
||||
fs.writeFileSync('./static/' + dest, uglify.minify(orig_code).code, 'utf8');
|
||||
winston.info('compressed ' + item + ' into ' + dest);
|
||||
}
|
||||
}
|
||||
|
|
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue