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

Commit

Permalink
feat: minify html
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Feb 23, 2024
1 parent ffd2209 commit 026bd72
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
key: ${{ runner.os }}-bun-turbo-${{ hashFiles('**/turbo.json') }}

- name: Install dependencies
run: bun install --frozen-lockfile
run: bun --bun install --frozen-lockfile

- name: Lint & Vite Build
# Sharp is buggy w/Bun.
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@
"@sherifforg/types": "^3.0.0",
"@types/bun": "^1.0.7",
"@types/eslint": "^8.56.3",
"@types/html-minifier-terser": "^7.0.2",
"@types/pathfinding": "^0.0.9",
"@vite-pwa/assets-generator": "^0.2.4",
"browserslist": "^4.23.0",
"browserslist-to-esbuild": "^2.1.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-sheriff": "^18.1.0",
"eslint-define-config": "^2.1.0",
"html-minifier-terser": "^7.2.0",
"lightningcss": "^1.24.0",
"prettier": "3.2.5",
"turbo": "^1.12.4",
Expand Down
23 changes: 23 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { browserslistToTargets } from "lightningcss";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import webfontDownload from "vite-plugin-webfont-dl";
import { minify } from "html-minifier-terser";

const browsersList = browserslist();
const basename = "/PHS-Map/";
Expand All @@ -31,6 +32,28 @@ export default defineConfig({
},
plugins: [
webfontDownload(["https://fonts.googleapis.com/css?family=Lato"]),
{
name: "html-minify", // Name of the plugin
transformIndexHtml: {
order: "post",
handler: async (html: string): Promise<string> =>
minify(html, {
removeAttributeQuotes: true,
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
collapseBooleanAttributes: true,
minifyURLs: true,
collapseInlineTagWhitespace: true,
decodeEntities: true,
noNewlinesBeforeTagClose: true,
removeStyleLinkTypeAttributes: true,
removeScriptTypeAttributes: true,
}),
},
},
VitePWA({
strategies: "injectManifest",
injectManifest: {
Expand Down

0 comments on commit 026bd72

Please sign in to comment.