Minify Astro files with HTMLNano and CSSNano
npm install --save astro-htmlnanoMinify Astro files with HTMLNano and CSSNano
Parameters:
- options (
HtmlnanoOptions) - The HTMLNano options to use when transforming the HTML files - preset (
HtmlnanoPreset) - The HTMLNano preset to use
returns: (_context: APIContext<Record<string, any>, Record<string, string>>, next: MiddlewareNext) => Promise
Create ./src/middleware.ts with the following content:
import { getAstroHTMLNano } from "astro-htmlnano"
export const onRequest = getAstroHTMLNano()Transform Astro files with PostHTML
npm install --save astro-posthtmlTransform Astro files with PostHTML
Parameters:
- plugins (
Plugin<PostHTMLUseThis>[]) - The posthtml plugins to use when transforming the HTML files - options (
Options) - The posthtml options
returns: (_context: APIContext<Record<string, any>, Record<string, string>>, next: MiddlewareNext) => Promise
Create ./src/middleware.ts with the following content:
import { getAstroPostHTML } from "astro-posthtml"
import htmlnano from "htmlnano"
export const onRequest = process.env.NODE_ENV === "production" ? getAstroPostHTML([htmlnano()]) : undefinedYou can sponsor my work here:
https://github.com/sponsors/aminya
Pull requests, issues and feature requests are welcome. See the Contributing guide.