mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(server) combine: add minify
This commit is contained in:
parent
d9957c52d7
commit
2864512018
1 changed files with 26 additions and 8 deletions
|
|
@ -170,7 +170,7 @@
|
|||
lRet = Util.exec(Route, lData);
|
||||
|
||||
if (!lRet)
|
||||
lRet = combine(lPath, pRes);
|
||||
lRet = combine(lData);
|
||||
|
||||
if (!lRet) {
|
||||
lName = lData.name;
|
||||
|
|
@ -204,19 +204,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
function combine(path, res) {
|
||||
var names,
|
||||
function combine(params) {
|
||||
var names, i, n, name, minName,
|
||||
config = main.config,
|
||||
dir = DIR,
|
||||
COMBINE = '/combine',
|
||||
p = params,
|
||||
path = params.name,
|
||||
COMBINE = '/combine/',
|
||||
isCombine = Util.isContainStrAtBegin(path, COMBINE);
|
||||
|
||||
if (isCombine) {
|
||||
path = Util.removeStrOneTime(path, COMBINE);
|
||||
names = path.split(':');
|
||||
console.log(names, DIR);
|
||||
files.readPipe(names, dir, res, function(error) {
|
||||
Util.log(error);
|
||||
main.sendError(res);
|
||||
n = names.length;
|
||||
|
||||
if (config.minify)
|
||||
for (i = 0; i < n; i++) {
|
||||
name = Path.join(DIR, names[i]);
|
||||
minName = Minify.getName(name);
|
||||
if (name !== minName) {
|
||||
names[i] = minName;
|
||||
dir = '';
|
||||
}
|
||||
}
|
||||
|
||||
console.log(names);
|
||||
|
||||
files.readPipe(names, dir, p.response, function(error) {
|
||||
if (error) {
|
||||
Util.log(error);
|
||||
main.sendError(params, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue