mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
resolved bug with js-minification
This commit is contained in:
parent
df399b34de
commit
d6b1111325
2 changed files with 31 additions and 7 deletions
20
minify.js
20
minify.js
|
|
@ -1,10 +1,14 @@
|
|||
/* Модуль сжатия js-скриптов*/
|
||||
/* Модуль сжатия js-скриптов и css*/
|
||||
/*
|
||||
https://github.com/GoalSmashers/clean-css
|
||||
*/
|
||||
exports.jsScripts=jsScripts;
|
||||
|
||||
function jsScripts(){
|
||||
|
||||
|
||||
/* функция сжимает js-скрипты
|
||||
* и сохраняет их с именем .min.js
|
||||
*/
|
||||
exports.jsScripts=function jsScripts(){
|
||||
'use strict';
|
||||
|
||||
/* подключаем модуль uglify-js
|
||||
|
|
@ -15,11 +19,12 @@ function jsScripts(){
|
|||
var jsp = require("uglify-js").parser;
|
||||
var pro = require("uglify-js").uglify;
|
||||
}catch(error){
|
||||
return console.log('ERROR. error loading minificatoin js\n' +
|
||||
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' +
|
||||
error);
|
||||
return false;
|
||||
}
|
||||
|
||||
var fs = require('fs');
|
||||
|
|
@ -78,4 +83,11 @@ function jsScripts(){
|
|||
error?console.log(error):dataReaded();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/* функция сжимает css-стили
|
||||
* и сохраняет их с именем .min.css
|
||||
*/
|
||||
exports.cssStyles=function cssStyles(){
|
||||
'use strict';
|
||||
};
|
||||
18
server.js
18
server.js
|
|
@ -113,9 +113,15 @@ CloudServer.Minify={
|
|||
scripts : function(){
|
||||
if(CloudServer.Minimize.scriptSize){
|
||||
var lMinify = require('./minify');
|
||||
lMinify.jsScripts();
|
||||
var lResult_b=lMinify.jsScripts();
|
||||
/* if we get false, files wasn't minified
|
||||
* error ocured
|
||||
*/
|
||||
CloudServer.Minify.done=(lResult_b===undefined?true:false);
|
||||
}
|
||||
}
|
||||
},
|
||||
/* свойство показывающее случилась ли ошибка*/
|
||||
done: false
|
||||
};
|
||||
|
||||
//var DirContent;
|
||||
|
|
@ -428,7 +434,13 @@ CloudServer._readDir=function (pError, pFiles)
|
|||
* минифицированый
|
||||
*/
|
||||
lIndex=lIndex.toString();
|
||||
CloudServer.Minimize.scriptSize?
|
||||
|
||||
/* if scripts shoud be minified and
|
||||
* minification proceed sucessfully
|
||||
* we include minified version of
|
||||
* clien.js to index.html
|
||||
*/
|
||||
(CloudServer.Minimize.scriptSize && CloudServer.Minify.done)?
|
||||
lIndex=lIndex.replace('client.js','client.min.js'):'';
|
||||
|
||||
lIndex=lIndex.toString().replace('<div id=fm class=no-js>','<div id=fm class=no-js>'+lList);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue