mirror of
https://github.com/xHyroM/website.git
synced 2024-12-22 20:41:05 +01:00
chore: change config & integrations to use TypeScript
This commit is contained in:
parent
b15138a192
commit
32ad10ce84
4 changed files with 118 additions and 5 deletions
|
@ -1,14 +1,15 @@
|
|||
import type { AstroIntegration } from "astro";
|
||||
import { minify } from "html-minifier";
|
||||
import { writeFile, readFile } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export default () => {
|
||||
export default (): AstroIntegration => {
|
||||
return {
|
||||
name: "hyro-minify",
|
||||
hooks: {
|
||||
"astro:build:done": async (opts) => {
|
||||
for (const route of opts.routes) {
|
||||
const content = await readFile(fileURLToPath(route.distURL), "utf-8");
|
||||
const content = await readFile(fileURLToPath(route.distURL!), "utf-8");
|
||||
const minified = await minify(content, {
|
||||
removeAttributeQuotes: true,
|
||||
collapseWhitespace: true,
|
||||
|
@ -19,8 +20,8 @@ export default () => {
|
|||
minifyURLs: true,
|
||||
});
|
||||
|
||||
await writeFile(fileURLToPath(route.distURL), minified, "utf-8");
|
||||
console.log(`Minified ${route.distURL.pathname}`)
|
||||
await writeFile(fileURLToPath(route.distURL!), minified, "utf-8");
|
||||
console.log(`Minified ${route.distURL!.pathname}`)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ import compress from "astro-compress";
|
|||
import prefetch from "@astrojs/prefetch";
|
||||
|
||||
import robotsTxt from "astro-robots-txt";
|
||||
import minify from "./astro-integrations/minify/index.mjs";
|
||||
import minify from "./astro-integrations/minify";
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
109
package-lock.json
generated
109
package-lock.json
generated
|
@ -18,6 +18,9 @@
|
|||
"fireworks-js": "^2.10.0",
|
||||
"html-minifier": "^4.0.0",
|
||||
"tailwindcss": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/html-minifier": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@altano/tiny-async-pool": {
|
||||
|
@ -816,6 +819,25 @@
|
|||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/clean-css": {
|
||||
"version": "4.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/clean-css/-/clean-css-4.2.6.tgz",
|
||||
"integrity": "sha512-Ze1tf+LnGPmG6hBFMi0B4TEB0mhF7EiMM5oyjLDNPE9hxrPU0W+5+bHvO+eFPA+bt0iC1zkQMoU/iGdRVjcRbw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/clean-css/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/css-tree": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/css-tree/-/css-tree-2.0.0.tgz",
|
||||
|
@ -863,6 +885,17 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/html-escaper/-/html-escaper-3.0.0.tgz",
|
||||
"integrity": "sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw=="
|
||||
},
|
||||
"node_modules/@types/html-minifier": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/html-minifier/-/html-minifier-4.0.2.tgz",
|
||||
"integrity": "sha512-4IkmkXJP/25R2fZsCHDX2abztXuQRzUAZq39PfCMz2loLFj8vS9y7aF6vDl58koXSTpsF+eL4Lc5Y4Aww/GCTQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/clean-css": "*",
|
||||
"@types/relateurl": "*",
|
||||
"@types/uglify-js": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/html-minifier-terser": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-7.0.0.tgz",
|
||||
|
@ -904,6 +937,12 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
|
||||
"integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
|
||||
},
|
||||
"node_modules/@types/relateurl": {
|
||||
"version": "0.2.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/relateurl/-/relateurl-0.2.29.tgz",
|
||||
"integrity": "sha512-QSvevZ+IRww2ldtfv1QskYsqVVVwCKQf1XbwtcyyoRvLIQzfyPhj/C+3+PKzSDRdiyejaiLgnq//XTkleorpLg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
|
||||
|
@ -925,6 +964,24 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/uglify-js": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.17.1.tgz",
|
||||
"integrity": "sha512-GkewRA4i5oXacU/n4MA9+bLgt5/L3F1mKrYvFGm7r2ouLXhRKjuWwo9XHNnbx6WF3vlGW21S3fCvgqxvxXXc5g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"source-map": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/uglify-js/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/unist": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||
|
@ -8546,6 +8603,24 @@
|
|||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"@types/clean-css": {
|
||||
"version": "4.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/clean-css/-/clean-css-4.2.6.tgz",
|
||||
"integrity": "sha512-Ze1tf+LnGPmG6hBFMi0B4TEB0mhF7EiMM5oyjLDNPE9hxrPU0W+5+bHvO+eFPA+bt0iC1zkQMoU/iGdRVjcRbw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"source-map": "^0.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@types/css-tree": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/css-tree/-/css-tree-2.0.0.tgz",
|
||||
|
@ -8593,6 +8668,17 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/html-escaper/-/html-escaper-3.0.0.tgz",
|
||||
"integrity": "sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw=="
|
||||
},
|
||||
"@types/html-minifier": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/html-minifier/-/html-minifier-4.0.2.tgz",
|
||||
"integrity": "sha512-4IkmkXJP/25R2fZsCHDX2abztXuQRzUAZq39PfCMz2loLFj8vS9y7aF6vDl58koXSTpsF+eL4Lc5Y4Aww/GCTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/clean-css": "*",
|
||||
"@types/relateurl": "*",
|
||||
"@types/uglify-js": "*"
|
||||
}
|
||||
},
|
||||
"@types/html-minifier-terser": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-7.0.0.tgz",
|
||||
|
@ -8634,6 +8720,12 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
|
||||
"integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
|
||||
},
|
||||
"@types/relateurl": {
|
||||
"version": "0.2.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/relateurl/-/relateurl-0.2.29.tgz",
|
||||
"integrity": "sha512-QSvevZ+IRww2ldtfv1QskYsqVVVwCKQf1XbwtcyyoRvLIQzfyPhj/C+3+PKzSDRdiyejaiLgnq//XTkleorpLg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/resolve": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
|
||||
|
@ -8655,6 +8747,23 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/uglify-js": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.17.1.tgz",
|
||||
"integrity": "sha512-GkewRA4i5oXacU/n4MA9+bLgt5/L3F1mKrYvFGm7r2ouLXhRKjuWwo9XHNnbx6WF3vlGW21S3fCvgqxvxXXc5g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@types/unist": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||
|
|
|
@ -21,5 +21,8 @@
|
|||
"fireworks-js": "^2.10.0",
|
||||
"html-minifier": "^4.0.0",
|
||||
"tailwindcss": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/html-minifier": "^4.0.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue