Permalink
Browse files

backtrack. uglify and clean are back, they are way faster than yui an…

…d less compilers.
  • Loading branch information...
1 parent 85582d2 commit 15a6db2dbcb30921c00b64a1f253865fc2adbb69 @jairajs89 committed Apr 5, 2013
Showing with 29 additions and 33 deletions.
  1. +6 −6 package.json
  2. +0 −10 run.js
  3. +23 −17 zerver.js
View
@@ -1,8 +1,9 @@
+
{
"author" : "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name" : "zerver",
"description" : "client-integrated webapp server",
- "version" : "0.9.9",
+ "version" : "0.9.10",
"license" : "MIT" ,
"repository" : {
"type" : "git",
@@ -12,11 +13,10 @@
"node" : "0.8.x"
},
"dependencies" : {
- "mime" : "1.2.7" ,
- "yuicompressor" : "2.4.7" ,
- "less" : "1.2.2"
- },
- "devDependencies" : {
+ "mime" : "1.2.7" ,
+ "uglify-js" : "1.3.4" ,
+ "clean-css" : "1.0.0" ,
+ "less" : "1.2.2" ,
"stalker" : "0.0.20" ,
"socket.io" : "0.6.18"
},
View
10 run.js
@@ -274,16 +274,6 @@ function main () {
return;
}
- try {
- require('socket.io');
- require('stalker' );
- }
- catch (err) {
- console.error('zerver debug mode requires dev dependencies to be installed');
- console.error('run this command: npm install --dev zerver');
- return;
- }
-
if (LOGGING) {
cli = setupCLI(function (line) {
if (child) {
View
@@ -1,11 +1,12 @@
/* Imports and static vars */
var less = require('less'),
+ clean = require('clean-css'),
fs = require('fs' ),
http = require('http'),
mime = require('mime'),
path = require('path'),
- yui = require('yuicompressor'),
+ uglify = require('uglify-js'),
url = require('url' ),
zlib = require('zlib');
@@ -600,29 +601,34 @@ function compileOutput (type, data, callback) {
return;
}
+ var code;
+
switch (type) {
case 'application/javascript':
case 'text/javascript':
data = data.replace(DEBUG_LINES, '');
- yui.compress(data, {
- 'charset' : 'utf8' ,
- 'type' : 'js' ,
- 'nomunge' : true
- }, function (err, compiledJS) {
- if ( !err ) {
- data = compiledJS;
- }
- callback(type, data);
- });
+ try {
+ var ast = uglify.parser.parse(data);
+ ast = uglify.uglify.ast_mangle(ast);
+ ast = uglify.uglify.ast_squeeze(ast);
+ code = uglify.uglify.gen_code(ast);
+ }
+ catch (err) {}
+ if (code) {
+ data = code;
+ }
+ callback(type, data);
break;
case 'text/css':
- less.render(data, { compress : true }, function (err, compiledCSS) {
- if ( !err ) {
- data = compiledCSS;
- }
- callback(type, data);
- });
+ try{
+ code = clean.process(data);
+ }
+ catch(err){}
+ if (code) {
+ data = code;
+ }
+ callback(type, data);
break;
default:

0 comments on commit 15a6db2

Please sign in to comment.