vite-plugin-singlefile-compression 1.3.3 → 1.4.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 +7 -2
- package/dist/index.js +11 -2
- package/dist/options.d.ts +5 -0
- package/dist/options.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,11 @@ See [src/options.ts](src/options.ts)
|
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
43
|
export interface Options {
|
|
44
|
+
/**
|
|
45
|
+
* Rename index.html
|
|
46
|
+
*/
|
|
47
|
+
rename?: string
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
|
|
46
51
|
* @default defaultHtmlMinifierTerserOptions
|
|
@@ -96,7 +101,7 @@ vite v6.0.7 building for production...
|
|
|
96
101
|
✓ 45 modules transformed.
|
|
97
102
|
rendering chunks (1)...
|
|
98
103
|
|
|
99
|
-
vite-plugin-singlefile-compression 1.
|
|
104
|
+
vite-plugin-singlefile-compression 1.4.0 building...
|
|
100
105
|
|
|
101
106
|
file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
102
107
|
101.56 KiB -> 46.32 KiB
|
|
@@ -104,7 +109,7 @@ vite-plugin-singlefile-compression 1.3.3 building...
|
|
|
104
109
|
Finish.
|
|
105
110
|
|
|
106
111
|
dist/index.html 47.42 kB
|
|
107
|
-
✓ built in
|
|
112
|
+
✓ built in 698ms
|
|
108
113
|
```
|
|
109
114
|
|
|
110
115
|

|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,16 @@ function setConfig(config) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async function generateBundle(bundle, config, options) {
|
|
51
|
-
console.log(pc.cyan('\n\nvite-plugin-singlefile-compression ' + version) + pc.green(' building...'));
|
|
51
|
+
console.log(pc.reset('') + pc.cyan('\n\nvite-plugin-singlefile-compression ' + version) + pc.green(' building...'));
|
|
52
|
+
// rename
|
|
53
|
+
if (options.rename
|
|
54
|
+
&& options.rename !== "index.html"
|
|
55
|
+
&& ("index.html" in bundle)
|
|
56
|
+
&& !(options.rename in bundle)) {
|
|
57
|
+
bundle[options.rename] = bundle["index.html"];
|
|
58
|
+
bundle[options.rename].fileName = options.rename;
|
|
59
|
+
delete bundle["index.html"];
|
|
60
|
+
}
|
|
52
61
|
const distURL = pathToFileURL(config.build.outDir).href + '/';
|
|
53
62
|
const globalDelete = new Set();
|
|
54
63
|
const globalDoNotDelete = new Set();
|
|
@@ -206,7 +215,7 @@ async function generateBundle(bundle, config, options) {
|
|
|
206
215
|
// finish
|
|
207
216
|
htmlChunk.source = newHtml;
|
|
208
217
|
console.log("\n"
|
|
209
|
-
+ " " + pc.underline(pc.cyan(distURL) + pc.greenBright(htmlFileName)) + '\n'
|
|
218
|
+
+ " " + pc.underline(pc.cyan(distURL) + pc.greenBright(bundle[htmlFileName].fileName)) + '\n'
|
|
210
219
|
+ " " + pc.gray(KiB(oldSize) + " -> ") + pc.cyanBright(KiB(newHtml.length)) + '\n');
|
|
211
220
|
// delete assets
|
|
212
221
|
for (const name of thisDel) {
|
package/dist/options.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Options as htmlMinifierOptions } from 'html-minifier-terser';
|
|
2
2
|
import { compressFormat } from './compress.js';
|
|
3
3
|
export interface Options {
|
|
4
|
+
/**
|
|
5
|
+
* Rename index.html
|
|
6
|
+
*/
|
|
7
|
+
rename?: string;
|
|
4
8
|
/**
|
|
5
9
|
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
|
|
6
10
|
* @default defaultHtmlMinifierTerserOptions
|
|
@@ -41,6 +45,7 @@ export interface Options {
|
|
|
41
45
|
}
|
|
42
46
|
export declare const defaultHtmlMinifierTerserOptions: htmlMinifierOptions;
|
|
43
47
|
export interface innerOptions {
|
|
48
|
+
rename?: string;
|
|
44
49
|
htmlMinifierTerser: htmlMinifierOptions | false;
|
|
45
50
|
tryInlineHtmlAssets: boolean;
|
|
46
51
|
removeInlinedAssetFiles: boolean;
|
package/dist/options.js
CHANGED
|
@@ -9,6 +9,7 @@ export const defaultHtmlMinifierTerserOptions = {
|
|
|
9
9
|
export function getInnerOptions(opt) {
|
|
10
10
|
opt ||= {};
|
|
11
11
|
return {
|
|
12
|
+
rename: opt.rename && opt.rename.replace(/(\.(html?)?)?$/, '.html'),
|
|
12
13
|
htmlMinifierTerser: opt.htmlMinifierTerser == null || opt.htmlMinifierTerser === true
|
|
13
14
|
? defaultHtmlMinifierTerserOptions
|
|
14
15
|
: opt.htmlMinifierTerser,
|