Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 026bd72

Browse files
committed
feat: minify html
1 parent ffd2209 commit 026bd72

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
key: ${{ runner.os }}-bun-turbo-${{ hashFiles('**/turbo.json') }}
4444

4545
- name: Install dependencies
46-
run: bun install --frozen-lockfile
46+
run: bun --bun install --frozen-lockfile
4747

4848
- name: Lint & Vite Build
4949
# Sharp is buggy w/Bun.

bun.lockb

3.83 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
"@sherifforg/types": "^3.0.0",
4444
"@types/bun": "^1.0.7",
4545
"@types/eslint": "^8.56.3",
46+
"@types/html-minifier-terser": "^7.0.2",
4647
"@types/pathfinding": "^0.0.9",
4748
"@vite-pwa/assets-generator": "^0.2.4",
4849
"browserslist": "^4.23.0",
4950
"browserslist-to-esbuild": "^2.1.1",
50-
"eslint": "^8.56.0",
51+
"eslint": "^8.57.0",
5152
"eslint-config-sheriff": "^18.1.0",
5253
"eslint-define-config": "^2.1.0",
54+
"html-minifier-terser": "^7.2.0",
5355
"lightningcss": "^1.24.0",
5456
"prettier": "3.2.5",
5557
"turbo": "^1.12.4",

vite.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { browserslistToTargets } from "lightningcss";
55
import { defineConfig } from "vite";
66
import { VitePWA } from "vite-plugin-pwa";
77
import webfontDownload from "vite-plugin-webfont-dl";
8+
import { minify } from "html-minifier-terser";
89

910
const browsersList = browserslist();
1011
const basename = "/PHS-Map/";
@@ -31,6 +32,28 @@ export default defineConfig({
3132
},
3233
plugins: [
3334
webfontDownload(["https://fonts.googleapis.com/css?family=Lato"]),
35+
{
36+
name: "html-minify", // Name of the plugin
37+
transformIndexHtml: {
38+
order: "post",
39+
handler: async (html: string): Promise<string> =>
40+
minify(html, {
41+
removeAttributeQuotes: true,
42+
collapseWhitespace: true,
43+
removeComments: true,
44+
removeRedundantAttributes: true,
45+
useShortDoctype: true,
46+
removeEmptyAttributes: true,
47+
collapseBooleanAttributes: true,
48+
minifyURLs: true,
49+
collapseInlineTagWhitespace: true,
50+
decodeEntities: true,
51+
noNewlinesBeforeTagClose: true,
52+
removeStyleLinkTypeAttributes: true,
53+
removeScriptTypeAttributes: true,
54+
}),
55+
},
56+
},
3457
VitePWA({
3558
strategies: "injectManifest",
3659
injectManifest: {

0 commit comments

Comments
 (0)