使用nodejs压缩文件

const fs = require('fs');
const zlib = require('zlib');
const gzip = zlib.createGzip();

const srcFile = './yarn.lock'; // 要压缩的文件
const distFile = 'yarn.lock.gz'; // 压缩后的文件名

const writeStream = fs.createWriteStream(distFile);
fs.createReadStream(srcFile).pipe(gzip).pipe(writeStream);

posted @ 2021-03-07 19:37  bronana  阅读(387)  评论(0编辑  收藏  举报