zcompress-vite-plugin 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +90 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,20 +1,22 @@
1
- # zcompress Vite Plugin
1
+ # zcompress-vite-plugin · 中文
2
2
 
3
- High-performance multi-threaded asset compression for Vite production builds, powered by [zcompress](https://github.com/luochuan2008/zcompress) (Zig).
3
+ Vite 生产构建资源压缩插件 gzip / zstd / brotli,多线程并行,比 Node.js 方案快 5-10 倍。
4
4
 
5
- ## Features
5
+ ## 安装
6
6
 
7
- - 🧵 **Multi-threaded** — all CPU cores, not just one
8
- - **5-10x faster** than Node.js compression plugins
9
- - 📦 **gzip**, **zstd**, **brotli** — all three algorithms
10
- - 💾 **Incremental cache** — skip unchanged files
7
+ ```bash
8
+ npm install zcompress-vite-plugin --save-dev
9
+ ```
11
10
 
12
- ## Quick Start
11
+ 安装后自动下载对应平台的 zcompress 二进制。如果下载失败,手动安装:
13
12
 
14
13
  ```bash
15
- npm install zcompress-vite-plugin --save-dev
14
+ brew install zcompress # macOS
15
+ zig build install # 从源码编译
16
16
  ```
17
17
 
18
+ ## 使用
19
+
18
20
  ```js
19
21
  // vite.config.js
20
22
  import zcompress from 'zcompress-vite-plugin';
@@ -23,24 +25,93 @@ export default {
23
25
  plugins: [
24
26
  zcompress({
25
27
  algo: 'gzip', // 'gzip' | 'zstd' | 'brotli'
26
- level: 6, // 1-9
27
- threads: 4, // 0 = auto
28
- cache: true, // skip unchanged files
28
+ level: 6, // 压缩级别 1-9
29
+ threads: 4, // 线程数,0=自动
30
+ cache: true, // 跳过未修改文件
31
+ verbose: true, // 显示详细输出
29
32
  })
30
33
  ]
31
34
  };
32
35
  ```
33
36
 
34
- After `vite build`, you'll get a `dist-compressed/` folder with `.gz` (or `.zst`/`.br`) files.
37
+ `vite build` 后,`dist-compressed/` 目录下就是压缩后的文件:
38
+
39
+ ```
40
+ dist-compressed/
41
+ ├── index.html.gz
42
+ ├── style.css.gz
43
+ ├── app.js.gz
44
+ └── logo.svg.gz
45
+ ```
46
+
47
+ 配合 Nginx 的 `gzip_static on` 直接使用。
48
+
49
+ ## 选项
50
+
51
+ | 选项 | 类型 | 默认值 | 说明 |
52
+ |------|------|--------|------|
53
+ | `algo` | `'gzip' \| 'zstd' \| 'brotli'` | `'gzip'` | 压缩算法 |
54
+ | `level` | `number` | `6` | 压缩级别 (1-9) |
55
+ | `threads` | `number` | `0` | 线程数 (0=CPU 核心数) |
56
+ | `verbose` | `boolean` | `false` | 显示详细输出 |
57
+ | `cache` | `boolean` | `false` | 跳过未修改文件 |
58
+ | `include` | `string[]` | `[]` | 额外压缩的扩展名 (如 `['.ts']`) |
59
+ | `exclude` | `string[]` | `[]` | 排除的扩展名 (如 `['.map']`) |
60
+ | `binaryPath` | `string` | 自动 | 手动指定二进制路径 |
35
61
 
36
- ## How It Works
62
+ ## 默认压缩的文件类型
37
63
 
38
- The plugin ships a JS wrapper. On `npm install`, it downloads the prebuilt Zig binary for your platform from GitHub Releases. If the download fails (air-gapped, unsupported arch), it falls back to looking for `zcompress` in your PATH.
64
+ `.js` `.mjs` `.cjs` `.css` `.html` `.htm` `.json` `.svg` `.png` `.jpg` `.jpeg` `.gif` `.ico` `.ttf` `.woff` `.woff2` `.xml` `.csv` `.wasm`
65
+
66
+ ## License
67
+
68
+ MIT
69
+
70
+ ---
71
+
72
+ # zcompress-vite-plugin · English
73
+
74
+ High-performance multi-threaded asset compression for Vite production builds. 5-10x faster than Node.js alternatives.
75
+
76
+ ## Install
39
77
 
40
78
  ```bash
41
- # Manual install (if auto-download fails)
42
- brew install zcompress # macOS
43
- zig build install # from source
79
+ npm install zcompress-vite-plugin --save-dev
80
+ ```
81
+
82
+ The correct platform binary is downloaded automatically. If that fails:
83
+
84
+ ```bash
85
+ brew install zcompress # macOS
86
+ zig build install # from source
87
+ ```
88
+
89
+ ## Usage
90
+
91
+ ```js
92
+ // vite.config.js
93
+ import zcompress from 'zcompress-vite-plugin';
94
+
95
+ export default {
96
+ plugins: [
97
+ zcompress({
98
+ algo: 'brotli', // 'gzip' | 'zstd' | 'brotli'
99
+ level: 11, // 1-9
100
+ threads: 0, // 0 = auto
101
+ cache: true, // skip unchanged files
102
+ })
103
+ ]
104
+ };
105
+ ```
106
+
107
+ After `vite build`, find compressed assets in `dist-compressed/`:
108
+
109
+ ```
110
+ dist-compressed/
111
+ ├── index.html.br
112
+ ├── style.css.br
113
+ ├── app.js.br
114
+ └── logo.svg.br
44
115
  ```
45
116
 
46
117
  ## Options
@@ -49,7 +120,7 @@ zig build install # from source
49
120
  |--------|------|---------|-------------|
50
121
  | `algo` | `'gzip' \| 'zstd' \| 'brotli'` | `'gzip'` | Compression algorithm |
51
122
  | `level` | `number` | `6` | Compression level (1-9) |
52
- | `threads` | `number` | `0` | Thread count (0 = auto) |
123
+ | `threads` | `number` | `0` | Thread count (0=auto) |
53
124
  | `verbose` | `boolean` | `false` | Verbose output |
54
125
  | `cache` | `boolean` | `false` | Skip unchanged files |
55
126
  | `include` | `string[]` | `[]` | Extra extensions to compress |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcompress-vite-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "High-performance multi-threaded asset compression for Vite — powered by Zig",
5
5
  "type": "module",
6
6
  "main": "index.js",