vite-plugin-singlefile-compression 1.0.1 → 1.0.2
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.
- package/README.md +2 -2
- package/package.json +2 -3
- package/README-zh-CN.md +0 -93
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Using `npm` to install
|
|
|
19
19
|
npm i vite-plugin-singlefile-compression
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Then modify [vite.config.ts](
|
|
22
|
+
Then modify [vite.config.ts](test/vite.config.ts#L14)
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
// Import singleFileCompression
|
|
@@ -35,7 +35,7 @@ export default defineConfig({
|
|
|
35
35
|
],
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Then modify [src/router/index.ts](
|
|
38
|
+
Then modify [src/router/index.ts](test/src/router/index.ts#L5) , change `createWebHistory` to `createWebHashHistory`
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
const router = createRouter({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-singlefile-compression",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"package.json",
|
|
9
9
|
"package-lock.json",
|
|
10
10
|
"LICENSE.txt",
|
|
11
|
-
"README.md"
|
|
12
|
-
"README-zh-CN.md"
|
|
11
|
+
"README.md"
|
|
13
12
|
],
|
|
14
13
|
"type": "module",
|
|
15
14
|
"scripts": {
|
package/README-zh-CN.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# vite plugin singlefile compression
|
|
2
|
-
|
|
3
|
-
该插件使用 gzip 将所有 JavaScript、CSS、图片等资源压缩后,嵌入到 `dist/index.html` ,方便作为单个 HTML 文件分享。
|
|
4
|
-
|
|
5
|
-
接收方可以直接使用浏览器打开,无需手动解压文件。
|
|
6
|
-
|
|
7
|
-
改编自 [vite-plugin-singlefile](https://www.npmjs.com/package/vite-plugin-singlefile)
|
|
8
|
-
|
|
9
|
-
### README Language
|
|
10
|
-
|
|
11
|
-
> [English](README.md)
|
|
12
|
-
> 简体中文
|
|
13
|
-
|
|
14
|
-
## 安装
|
|
15
|
-
|
|
16
|
-
使用 `npm` 安装
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
npm i vite-plugin-singlefile-compression
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
然后修改 [vite.config.ts](https://github.com/bddjr/vite-plugin-singlefile-compression/blob/main/test/vite.config.ts#L14)
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
// 导入 singleFileCompression
|
|
26
|
-
import singleFileCompression from 'vite-plugin-singlefile-compression'
|
|
27
|
-
|
|
28
|
-
// https://vite.dev/config/
|
|
29
|
-
export default defineConfig({
|
|
30
|
-
plugins: [
|
|
31
|
-
vue(),
|
|
32
|
-
vueDevTools(),
|
|
33
|
-
// 添加 singleFileCompression
|
|
34
|
-
singleFileCompression(),
|
|
35
|
-
],
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
然后修改 [src/router/index.ts](https://github.com/bddjr/vite-plugin-singlefile-compression/blob/main/test/src/router/index.ts#L5) ,将 `createWebHistory` 改为 `createWebHashHistory`
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
const router = createRouter({
|
|
42
|
-
history: createWebHashHistory(),
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## 效果
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
vite v5.4.11 building for production...
|
|
49
|
-
✓ 45 modules transformed.
|
|
50
|
-
rendering chunks (1)...
|
|
51
|
-
|
|
52
|
-
vite-plugin-singlefile-compression building...
|
|
53
|
-
|
|
54
|
-
file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
55
|
-
97.2 KiB -> 50.91 KiB
|
|
56
|
-
|
|
57
|
-
Finish.
|
|
58
|
-
|
|
59
|
-
dist/index.html 52.13 kB
|
|
60
|
-
✓ built in 778ms
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```html
|
|
64
|
-
<!DOCTYPE html>
|
|
65
|
-
<html>
|
|
66
|
-
<head>
|
|
67
|
-
<meta charset="UTF-8">
|
|
68
|
-
<link rel="icon" href="data:logo-_cUAdIX-.svg">
|
|
69
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
70
|
-
<title>Vite App</title>
|
|
71
|
-
<script type="module">fetch("data:application/gzip;base64,H4sI******AQA=").then(r=>r.blob()).then(b=>new Response(b.stream().pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob()).then(b=>import(b=URL.createObjectURL(b)).finally(()=>URL.revokeObjectURL(b)))</script>
|
|
72
|
-
</head>
|
|
73
|
-
<body>
|
|
74
|
-
<div id="app"></div>
|
|
75
|
-
</body>
|
|
76
|
-
</html>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Clone
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
git clone https://github.com/bddjr/vite-plugin-singlefile-compression
|
|
83
|
-
cd vite-plugin-singlefile-compression
|
|
84
|
-
npm i
|
|
85
|
-
cd test
|
|
86
|
-
npm i
|
|
87
|
-
cd ..
|
|
88
|
-
npm run build
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## License
|
|
92
|
-
|
|
93
|
-
[MIT](LICENSE.txt)
|