vite-plugin-zip-file 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 +3 -3
- package/lib/index.cjs +1 -0
- package/lib/{index.es.js → index.mjs} +0 -0
- package/package.json +3 -3
- package/plugin.config.js +1 -1
- package/lib/index.cjs.js +0 -1
package/README.md
CHANGED
|
@@ -25,8 +25,8 @@ npm install vite-plugin-zip-file --save-dev
|
|
|
25
25
|
|
|
26
26
|
# Usage
|
|
27
27
|
```javascript
|
|
28
|
-
import { defineConfig } from 'vite'
|
|
29
|
-
import {
|
|
28
|
+
import { defineConfig } from 'vite';
|
|
29
|
+
import { viteZip } from 'vite-plugin-zip-file';
|
|
30
30
|
import path from 'path';
|
|
31
31
|
import { fileURLToPath } from 'url';
|
|
32
32
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -34,7 +34,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
34
34
|
// https://vitejs.dev/config/
|
|
35
35
|
export default defineConfig({
|
|
36
36
|
plugins: [
|
|
37
|
-
|
|
37
|
+
viteZip({
|
|
38
38
|
folderPath: path.resolve(__dirname, 'dist'),
|
|
39
39
|
outPath: path.resolve(__dirname),
|
|
40
40
|
zipName: 'Test.zip'
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("path"),g=require("fs"),j=require("node:module"),m=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},r=m(v),i=m(g),q=j.createRequire(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs",document.baseURI).href),b=(e={folderPath:null,outPath:null,zipName:null})=>{let{folderPath:l,outPath:u,zipName:t}=e;if(!l||!u)throw new Error("config.folderPath and config.outPath is required.");l=r.default.resolve(l),u=r.default.resolve(u),t=t||l.split("/").pop()+".zip";const y=()=>{const h=q("jszip"),f=new h,a=function(n,o,c=""){const _=i.default.readdirSync(o);c+=o.split("/").pop()+"/",_.forEach(p=>{const s=r.default.join(o,"/",p);i.default.statSync(s).isDirectory()?a(n,s,c):n.file(c+p,i.default.readFileSync(s))})},d=(n=t)=>{const o=r.default.join(u,"/"+n);i.default.existsSync(o)&&i.default.unlinkSync(o)},S=function(){a(f,l),f.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}}).then(n=>{d(t),i.default.writeFileSync(r.default.join(u,"/",t),n)})};d(t),S()};return{name:"vite-plugin-zip-file",apply:"build",closeBundle(){y()}}};exports.viteZip=b;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-zip-file",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "zip files at build time.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "lib/index.cjs
|
|
7
|
-
"module": "lib/index.
|
|
6
|
+
"main": "lib/index.cjs",
|
|
7
|
+
"module": "lib/index.mjs",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"build": "vite build",
|
package/plugin.config.js
CHANGED
|
@@ -15,7 +15,7 @@ export default defineConfig({
|
|
|
15
15
|
lib: {
|
|
16
16
|
entry: path.resolve(__dirname, 'src/utils/vite-plugin-zip-flie.js'),
|
|
17
17
|
name: 'index',
|
|
18
|
-
fileName: (format) =>
|
|
18
|
+
fileName: (format) => format === 'cjs'? 'index.cjs': 'index.mjs',
|
|
19
19
|
formats: ['cjs', 'es']
|
|
20
20
|
},
|
|
21
21
|
rollupOptions: {
|
package/lib/index.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("path"),j=require("fs"),g=require("node:module"),m=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},r=m(v),i=m(j),q=g.createRequire(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs.js",document.baseURI).href),b=(e={folderPath:null,outPath:null,zipName:null})=>{let{folderPath:l,outPath:u,zipName:t}=e;if(!l||!u)throw new Error("config.folderPath and config.outPath is required.");l=r.default.resolve(l),u=r.default.resolve(u),t=t||l.split("/").pop()+".zip";const y=()=>{const h=q("jszip"),f=new h,a=function(n,o,s=""){const _=i.default.readdirSync(o);s+=o.split("/").pop()+"/",_.forEach(p=>{const c=r.default.join(o,"/",p);i.default.statSync(c).isDirectory()?a(n,c,s):n.file(s+p,i.default.readFileSync(c))})},d=(n=t)=>{const o=r.default.join(u,"/"+n);i.default.existsSync(o)&&i.default.unlinkSync(o)},S=function(){a(f,l),f.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}}).then(n=>{d(t),i.default.writeFileSync(r.default.join(u,"/",t),n)})};d(t),S()};return{name:"vite-plugin-zip-file",apply:"build",closeBundle(){y()}}};exports.viteZip=b;
|