vite-plugin-singlefile-compression 1.3.0 → 1.3.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/LICENSE.txt CHANGED
File without changes
package/README.md CHANGED
@@ -39,6 +39,54 @@ const router = createRouter({
39
39
 
40
40
  See [src/options.ts](src/options.ts)
41
41
 
42
+ ```ts
43
+ export interface Options {
44
+ /**
45
+ * https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
46
+ * @default defaultHtmlMinifierTerserOptions
47
+ */
48
+ htmlMinifierTerser?: htmlMinifierOptions | boolean
49
+
50
+ /**
51
+ * Try inline html used assets, if inlined or not used in JS.
52
+ * @default true
53
+ */
54
+ tryInlineHtmlAssets?: boolean
55
+
56
+ /**
57
+ * Remove inlined asset files.
58
+ * @default true
59
+ */
60
+ removeInlinedAssetFiles?: boolean
61
+
62
+ /**
63
+ * Try inline html icon, if icon is in public dir.
64
+ * @default true
65
+ */
66
+ tryInlineHtmlPublicIcon?: boolean
67
+
68
+ /**
69
+ * Remove inlined html icon files.
70
+ * @default true
71
+ */
72
+ removeInlinedPublicIconFiles?: boolean
73
+
74
+ /**
75
+ * Use Base128 to encode gzipped script.
76
+ * If false, use Base64.
77
+ * https://www.npmjs.com/package/base128-ascii
78
+ * @default true
79
+ */
80
+ useBase128?: boolean
81
+
82
+ /**
83
+ * Compress format.
84
+ * @default "deflate-raw"
85
+ */
86
+ compressFormat?: compressFormat
87
+ }
88
+ ```
89
+
42
90
  ## Effect
43
91
 
44
92
  https://bddjr.github.io/vite-plugin-singlefile-compression/
@@ -48,17 +96,19 @@ vite v6.0.7 building for production...
48
96
  ✓ 45 modules transformed.
49
97
  rendering chunks (1)...
50
98
 
51
- vite-plugin-singlefile-compression 1.3.0 building...
99
+ vite-plugin-singlefile-compression 1.3.2 building...
52
100
 
53
- file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
54
- 101.56 KiB -> 46.76 KiB
101
+ file:///d/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
102
+ 101.56 KiB -> 46.74 KiB
55
103
 
56
104
  Finish.
57
105
 
58
- dist/index.html 47.88 kB
59
- ✓ built in 677ms
106
+ dist/index.html 47.86 kB
107
+ ✓ built in 634ms
60
108
  ```
61
109
 
110
+ ![](effect.jpg)
111
+
62
112
  ## Clone
63
113
 
64
114
  ```
package/dist/KiB.d.ts CHANGED
File without changes
package/dist/KiB.js CHANGED
File without changes
File without changes
package/dist/compress.js CHANGED
File without changes
package/dist/dataurl.d.ts CHANGED
File without changes
package/dist/dataurl.js CHANGED
File without changes
File without changes
@@ -1,9 +1,9 @@
1
- import path from 'path';
2
1
  import fs from 'fs';
2
+ import { fileURLToPath } from 'url';
3
3
  const files = {
4
- base64: fs.readFileSync(path.join(import.meta.dirname, "template/base64.js")).toString(),
5
- base128: fs.readFileSync(path.join(import.meta.dirname, "template/base128.js")).toString(),
6
- assets: fs.readFileSync(path.join(import.meta.dirname, "template/assets.js")).toString().split('{"":""}', 2),
4
+ base64: fs.readFileSync(fileURLToPath(import.meta.resolve("./template/base64.js"))).toString(),
5
+ base128: fs.readFileSync(fileURLToPath(import.meta.resolve("./template/base128.js"))).toString(),
6
+ assets: fs.readFileSync(fileURLToPath(import.meta.resolve("./template/assets.js"))).toString().split('{"":""}', 2),
7
7
  };
8
8
  export const template = {
9
9
  base(script, format, useBase128) {
File without changes
File without changes
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
@@ -175,7 +175,7 @@ async function generateBundle(bundle, config, options) {
175
175
  const js = bundle[name];
176
176
  oldSize += js.code.length;
177
177
  // fix new URL
178
- newJSCode.push(`import.meta.url=location.origin+location.pathname.replace(/[^/]*$/,${JSON.stringify(name)})`);
178
+ newJSCode.push(`import.meta.url=new URL(${JSON.stringify(name)},location).href`);
179
179
  // do not delete not inlined asset
180
180
  for (const name of bundleAssetsNames) {
181
181
  const assetName = name.slice('assets/'.length);
package/dist/options.d.ts CHANGED
@@ -47,6 +47,6 @@ export interface innerOptions {
47
47
  tryInlineHtmlPublicIcon: boolean;
48
48
  removeInlinedPublicIconFiles: boolean;
49
49
  useBase128: boolean;
50
- compressFormat: "deflate-raw" | "deflate" | "gzip";
50
+ compressFormat: compressFormat;
51
51
  }
52
52
  export declare function getInnerOptions(opt?: Options): innerOptions;
package/dist/options.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-singlefile-compression",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [