。
var compressor = require('yuicompressor');
//Compressor Options:
var compressorOptions = {
charset: 'utf8',
type: 'js',
nomunge: false
}
/* List of files and file path. Just replace the file names and path with yours */
var file = [{
"path": "assets/www/modules/eApp/controllers/",
"type": "js",
"name": ["BuyOnlineController", "CustomerDetailsController", "DashboardController", "DashboardListingController", "DocumentUploadController", "HomeController", "KYCDetailsController", "PaymentAcknowledgementController", "PaymentController", "ProductListingController", "ReviewAndAcceptanceController"]
},
{
"path": "assets/www/modules/login/controllers/",
"type": "js",
"name": ["EappLoginController", "InboxController", "LandingController", "LoginController", "MenuController", "MyAccountController", "SyncForEappController"]
},
{
"path": "assets/www/lib/vendor/general/",
"type": "js",
"name": ["overlays"]
}];
function minify(i, j){
i = (i == undefined) ? 0 : i;
j = (j == undefined) ? 0 : j;
filePath = file[i].path;
fileType = file[i].type;
name = file[i].name[j];
fileName = filePath+name+"."+fileType;
minifiedFileName = filePath+name+".min."+fileType;
if(j == file[i].name.length - 1){
i += 1;
j = 0;
}
else
j += 1;
compressor.compress(fileName, compressorOptions, function(err, data, extra) {
var fs = require('fs');
fs.writeFile(minifiedFileName, data, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file "+minifiedFileName+" was saved successfully!");
if(i != file.length)
minify(i, j);
}
});
});
}
minify(0,0);
unixの場合、 'cat src1 src2 src3> dest'を使用してください。 –