Skip to content

Commit

Permalink
add compress.js
Browse files Browse the repository at this point in the history
auto compressing
  • Loading branch information
LandmineHQ committed Apr 1, 2024
1 parent 250b028 commit 84636b5
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
25 changes: 25 additions & 0 deletions compress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { add } from "node-7z";

// 定义要压缩的目录和压缩后的文件名
const sourceDir = "dist";
const outputZip = `${sourceDir}/dist.7z`;

console.log(`Compressing ${sourceDir} to ${outputZip}...`);

// 创建 Seven 对象
const myStream = add(outputZip, sourceDir);

// 监听压缩进度事件
myStream.on("progress", (progress) => {
console.log(`Compression progress: ${progress}%`);
});

// 监听压缩完成事件
myStream.on("end", () => {
console.log("Compression done");
});

// 监听错误事件
myStream.on("error", (err) => {
console.error("Compression error:", err);
});
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"private": true,
"type": "module",
"scripts": {
"compress": "node compress.js",
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"build": "run-p type-check \"build-only {@}\" -- && npm run compress",
"preview": "vite preview",
"test:unit": "vitest",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
Expand Down Expand Up @@ -38,6 +39,7 @@
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-vue": "^9.17.0",
"jsdom": "^24.0.0",
"node-7z": "^3.0.0",
"npm-run-all2": "^6.1.2",
"prettier": "^3.0.3",
"start-server-and-test": "^2.0.3",
Expand All @@ -47,4 +49,4 @@
"vitest": "^1.4.0",
"vue-tsc": "^2.0.6"
}
}
}

0 comments on commit 84636b5

Please sign in to comment.