vite-plugin-zip-file 3.1.1 → 4.0.0
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 +5 -10
- package/lib/index.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ npm install vite-plugin-zip-file --save-dev
|
|
|
32
32
|
| deleteFolder | Boolean | false | false | Whether to delete source files after compression is completed |
|
|
33
33
|
| withoutMainFolder | Boolean | false | false | The compressed file whether removes the outermost main folder. |
|
|
34
34
|
|
|
35
|
+
<br />
|
|
35
36
|
|
|
36
37
|
# Options(中文)
|
|
37
38
|
|
|
@@ -40,8 +41,8 @@ npm install vite-plugin-zip-file --save-dev
|
|
|
40
41
|
<tr>
|
|
41
42
|
<th>参数</th>
|
|
42
43
|
<th>类型</th>
|
|
43
|
-
<th width="
|
|
44
|
-
<th width="
|
|
44
|
+
<th width="75">必填</th>
|
|
45
|
+
<th width="95">默认值</th>
|
|
45
46
|
<th>说明</th>
|
|
46
47
|
</tr>
|
|
47
48
|
</thead>
|
|
@@ -89,15 +90,9 @@ npm install vite-plugin-zip-file --save-dev
|
|
|
89
90
|
<td>压缩后的文件是否去掉最外层文件夹</td>
|
|
90
91
|
</tr>
|
|
91
92
|
</tbody>
|
|
92
|
-
</table>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
</table>
|
|
100
94
|
|
|
95
|
+
<br />
|
|
101
96
|
|
|
102
97
|
# Usage
|
|
103
98
|
|
package/lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("path"),n=require("fs"),z=require("node:module");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("path"),n=require("fs"),z=require("node:module");var f=typeof document<"u"?document.currentScript:null;const E=z.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:f&&f.tagName.toUpperCase()==="SCRIPT"&&f.src||new URL("index.cjs",document.baseURI).href),o=i.sep,{cwd:v}=process,R={enabled:!0,folderPath:i.join(v(),"/dist"),outPath:i.resolve(v()),zipName:"",deleteFolder:!1,withoutMainFolder:!1},C=g=>{let F={...R,...g},{enabled:u,folderPath:s,outPath:d,zipName:r,deleteFolder:w,withoutMainFolder:b}=F;if(u=!!u,!s||!d)throw new Error("config.folderPath and config.outPath is required.");s=i.resolve(s),d=i.resolve(d),r=r||s.split(o).pop()+".zip";const j=()=>{const q=E("jszip"),p=new q,y=function(e,t,c="",l=0){const Z=n.readdirSync(t);b?l!==0&&(c+=t.split(o).pop()+o):c+=t.split(o).pop()+o,Z.forEach(h=>{const a=i.join(t,o,h);n.statSync(a).isDirectory()?y(e,a,c,l+1):e.file(c+h,n.readFileSync(a))})},m=(e=r)=>{const t=i.join(d,o+e);n.existsSync(t)&&n.unlinkSync(t)},S=e=>{n.readdirSync(e).forEach(c=>{const l=e+o+c;n.statSync(l).isDirectory()?S(l):n.unlinkSync(l)}),n.rmdirSync(e)},P=function(){y(p,s,"",0),p.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}}).then(e=>{m(r),n.writeFileSync(i.join(d,o,r),e),w&&S(s)})};m(r),P()};return{name:"vite-plugin-zip-file",apply:"build",closeBundle(){u&&j()}}};exports.viteZip=C;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-zip-file",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "zip files at build time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"jszip": "^3.10.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"vite": "^
|
|
39
|
+
"vite": "^6.2.0",
|
|
40
40
|
"@rollup/plugin-node-resolve": "^15.2.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|