Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit 2606959

Browse files
author
8to16
committed
compression
1 parent 7b46325 commit 2606959

3 files changed

Lines changed: 75 additions & 4 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"eslint-plugin-react-hooks": "^7.0.1",
3030
"eslint-plugin-react-refresh": "^0.4.24",
3131
"globals": "^16.5.0",
32-
"vite": "npm:rolldown-vite@7.2.5"
32+
"vite": "npm:rolldown-vite@7.2.5",
33+
"vite-plugin-compression2": "^2.4.0",
34+
"zstd-codec": "^0.1.5"
3335
},
3436
"pnpm": {
3537
"overrides": {

pnpm-lock.yaml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vite.config.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import { compression } from 'vite-plugin-compression2'
4+
import { ZstdCodec } from 'zstd-codec'
5+
import { Buffer } from 'buffer';
6+
7+
const zstdCompress = async (buf) => {
8+
return new Promise((resolve) => {
9+
ZstdCodec.run((zstd) => {
10+
const simple = new zstd.Simple();
11+
const compressed = simple.compress(buf, 3);
12+
resolve(Buffer.from(compressed));
13+
});
14+
});
15+
};
316

4-
// https://vite.dev/config/
517
export default defineConfig({
6-
plugins: [react()],
18+
plugins: [
19+
react(),
20+
compression({
21+
algorithm: 'brotliCompress',
22+
exclude: [/\.(br)$/, /\.(gz)$/],
23+
}),
24+
compression({
25+
algorithm: zstdCompress,
26+
filename: '[path][base].zst',
27+
exclude: [/\.(br)$/, /\.(gz)$/],
28+
}),
29+
],
730
base: './',
8-
})
31+
})

0 commit comments

Comments
 (0)