From 0dfa2cf5a49a6973cb0a40b52b223af90e5c5d53 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 8 Jun 2012 14:42:31 +0000 Subject: [PATCH] added new optional feture: css-minification --- minify.js | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/minify.js b/minify.js index ea558a05..3df954db 100644 --- a/minify.js +++ b/minify.js @@ -1,9 +1,4 @@ /* Модуль сжатия js-скриптов и css*/ -/* - https://github.com/GoalSmashers/clean-css -*/ - - /* функция сжимает js-скрипты * и сохраняет их с именем .min.js @@ -19,10 +14,10 @@ exports.jsScripts=function jsScripts(){ var jsp = require("uglify-js").parser; var pro = require("uglify-js").uglify; }catch(error){ - console.log('ERROR. error loading minificatoin js\n' + - 'to use minification you need to install uglify-js\n' + - 'npm install uglify-js\n' + - 'https://github.com/mishoo/UglifyJS\n' + + console.log('ERROR. error loading uglify-js\n' + + 'to use js-minification you need to install uglify-js\n' + + 'npm install uglify-js\n' + + 'https://github.com/mishoo/UglifyJS\n' + error); return false; } @@ -67,7 +62,11 @@ exports.jsScripts=function jsScripts(){ * если другой файл - ничего не деалем */ (pFileName===CLIENT_JS)? - console.log('file name of '+CLOUDFUNC_JS+' in '+CLIENT_JS+' changed. size:', + console.log('file name of ' + + CLOUDFUNC_JS + + ' in ' + + CLIENT_JS + + ' changed. size:', (final_code=final_code.replace(CLOUDFUNC_JS, CLOUDFUNC_JS.replace('.js', '.min.js'))).length): @@ -90,4 +89,19 @@ exports.jsScripts=function jsScripts(){ */ exports.cssStyles=function cssStyles(){ 'use strict'; + + var cleanCSS; + try{ + cleanCSS = require('clean-css'); + }catch(error){ + console.log('ERROR. error loading clean-css \n' + + 'to use css-minification you need to install clean-css \n' + + 'npm install clean-css\n' + + 'https://github.com/GoalSmashers/clean-css\n' + + error); + return false; + } + + var source = "a{font-weight:bold;font-color:red}"; + var minimized = cleanCSS.process(source); }; \ No newline at end of file