都能跟得上你不能傳遞從節點程序發送的選項-o
(these是有效的選擇,如果你使用的壓縮機中的一個節點程序),但是你可以在自己的
var compressor = require('yuicompressor');
var fs = require('fs');
compressor.compress('/path/to/file or String of JS', {
//Compressor Options:
charset: 'utf8',
type: 'js',
nomunge: true,
'line-break': 80
}, function(err, data, extra) {
//err If compressor encounters an error, it's stderr will be here
//data The compressed string, you write it out where you want it
//extra The stderr (warnings are printed here in case you want to echo them
if (err) throw err
fs.writeFileSync('./output.js', data)
});
寫入文件