mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added new optional feture: css-minification
This commit is contained in:
parent
d6b1111325
commit
0dfa2cf5a4
1 changed files with 24 additions and 10 deletions
34
minify.js
34
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);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue