Skip to content

Commit

Permalink
1.1.3 README
Browse files Browse the repository at this point in the history
  • Loading branch information
bddjr committed Dec 30, 2024
1 parent c8e77b9 commit 7e238b2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
78 changes: 47 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vite plugin singlefile compression

This plugin compresses all JavaScript, CSS, images, etc. resources using gzip and embeds them into `dist/index.html`, making it convenient to share as a single HTML file.
Compress all assets and embeds them into `dist/index.html`, making it convenient to share as a single HTML file.

The recipient can open it directly in the browser without manually unzipping the file.

Expand Down Expand Up @@ -60,35 +60,35 @@ const router = createRouter({
```ts
export interface Options {
/**
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
* @default defaultHtmlMinifierTerserOptions
*/
htmlMinifierTerser?: htmlMinifierOptions | boolean

/**
* Try inline html used assets, if inlined or not used in JS.
* @default true
*/
tryInlineHtmlAssets?: boolean

/**
* Remove inlined asset files.
* @default true
*/
removeInlinedAssetFiles?: boolean

/**
* Try inline html icon, if icon is in public dir.
* @default true
*/
tryInlineHtmlPublicIcon?: boolean

/**
* Remove inlined html icon files.
* @default true
*/
removeInlinedPublicIconFiles?: boolean
/**
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
* @default defaultHtmlMinifierTerserOptions
*/
htmlMinifierTerser?: htmlMinifierOptions | boolean;

/**
* Try inline html used assets, if inlined or not used in JS.
* @default true
*/
tryInlineHtmlAssets?: boolean;

/**
* Remove inlined asset files.
* @default true
*/
removeInlinedAssetFiles?: boolean;

/**
* Try inline html icon, if icon is in public dir.
* @default true
*/
tryInlineHtmlPublicIcon?: boolean;

/**
* Remove inlined html icon files.
* @default true
*/
removeInlinedPublicIconFiles?: boolean;
}
```
Expand All @@ -113,7 +113,23 @@ dist/index.html 53.60 kB
```
```html
<!DOCTYPE html><meta charset=UTF-8><link rel=icon href=data:><meta name=viewport content="width=device-width,initial-scale=1"><title>Vite App</title><script type=module>fetch("data:application/gzip;base64,********").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><div id=app></div>
<!DOCTYPE html><meta charset="UTF-8" /><link rel="icon" href="data:" /><meta
name="viewport"
content="width=device-width,initial-scale=1"
/><title>Vite App</title>
<script type="module">
fetch("data:application/gzip;base64,********")
.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>
<div id="app"></div>
```
## Clone
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-singlefile-compression",
"version": "1.1.2",
"version": "1.1.3",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down

0 comments on commit 7e238b2

Please sign in to comment.