nodejs 压缩js 和 css
npm install -g uglifyjs
npm install -g uglifycss
-----
uglifycss a.css b.css >all.min.css
uglifyjs a.js -o -m b.mi.js
gzip-i.js
const zlib = require("zlib");
const fs = require("fs");
const path = require("path");
//var args = require('minimist')(process.argv.slice(2));
//console.log(args);
//console.log(args.aa);
// 压缩
function gzip(source) {
// 处理输入和输出的文件路径
let sourcePath = path.join(__dirname, source);
let gzipPath = `${sourcePath}.gz`;
// 创建转化流
let gzip = zlib.createGzip();
// 创建可读流
let rs = fs.createReadStream(sourcePath);
// 创建可写流
let ws = fs.createWriteStream(gzipPath);
// 实现转化
rs.pipe(gzip).pipe(ws);
}
gzip("metisMenu.min.js");
gzip-i.bat
node gzip-i.js
pause
文档更新时间: 2021-08-19 08:00 作者:admin