Skip to content

Commit

Permalink
1.2.0 Add base128
Browse files Browse the repository at this point in the history
  • Loading branch information
bddjr committed Jan 7, 2025
1 parent 89d6815 commit 0d2f2b2
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 183 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright © 2024 bddjr
Copyright © 2024-2025 bddjr

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
129 changes: 0 additions & 129 deletions README-zh-CN.md

This file was deleted.

82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ The recipient can open it directly in the browser without manually unzipping the

Adapted from [vite-plugin-singlefile](https://www.npmjs.com/package/vite-plugin-singlefile)

### README Language

> English
> [简体中文](README-zh-CN.md)
## Install

Using `npm` to install
## Setup

```
npm i vite-plugin-singlefile-compression
Expand Down Expand Up @@ -60,35 +53,42 @@ 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;

/**
* Use Base128 to encode gzipped script.
* If false, use Base64.
* @default true
*/
useBase128?: boolean
}
```
Expand All @@ -101,15 +101,15 @@ vite v6.0.6 building for production...
45 modules transformed.
rendering chunks (1)...

vite-plugin-singlefile-compression 1.1.3 building...
vite-plugin-singlefile-compression 1.2.0 building...

file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
101.02 KiB -> 52.1 KiB
101.02 KiB -> 46.81 KiB

Finish.

dist/index.html 53.35 kB
built in 734ms
dist/index.html 47.93 kB
built in 687ms
```
## Clone
Expand Down
22 changes: 21 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import esbuild from 'esbuild'
import fs from 'fs'

const result = esbuild.buildSync({
let result = esbuild.buildSync({
entryPoints: [
"src/template.js",
"src/template-assets.js",
Expand All @@ -17,3 +17,23 @@ if (result.errors.length)
for (const i of result.outputFiles) {
fs.writeFileSync(i.path, i.text.replace(/;?\n?$/, ''))
}

result = esbuild.buildSync({
entryPoints: [
"src/template-base128.js",
],
outdir: "dist",
minify: true,
bundle: true,
write: false,
})

if (result.errors.length)
throw result.errors

for (const i of result.outputFiles) {
fs.writeFileSync(i.path,
i.text
.replace(/^\(\(\)=>\{/, '')
.replace(/;?\}\)\(\);\n$/, ''))
}
22 changes: 17 additions & 5 deletions package-lock.json

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

3 changes: 2 additions & 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.4",
"version": "1.2.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -42,6 +42,7 @@
"dependencies": {
"@types/html-minifier-terser": "^7.0.2",
"@types/node": "^22.9.3",
"base128-ascii": "^0.0.1",
"esbuild": "^0.24.0",
"html-minifier-terser": "^7.2.0",
"mime": "^4.0.4",
Expand Down
Loading

0 comments on commit 0d2f2b2

Please sign in to comment.