Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aminya/astro-plugins
Various astro plugins such as astro-htmlnano to minify Astro files with HTMLNano and CSSNano
https://github.com/aminya/astro-plugins
astro astro-plugin cssnano html-minifier htmlnano minify optimize posthtml
Last synced: 23 days ago
JSON representation
Various astro plugins such as astro-htmlnano to minify Astro files with HTMLNano and CSSNano
- Host: GitHub
- URL: https://github.com/aminya/astro-plugins
- Owner: aminya
- License: apache-2.0
- Created: 2023-10-02T08:06:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-29T14:52:58.000Z (9 months ago)
- Last Synced: 2024-05-01T23:19:00.378Z (9 months ago)
- Topics: astro, astro-plugin, cssnano, html-minifier, htmlnano, minify, optimize, posthtml
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/astro-htmlnano
- Size: 631 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
astro-htmlnano
> Minify Astro files with HTMLNano and CSSNano
## Install
```sh
npm install --save astro-htmlnano
```## Usage
### `getAstroHTMLNano` (function)
Minify 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>, next: MiddlewareNext) => Promise
Create `./src/middleware.ts` with the following content:
```ts
import { getAstroHTMLNano } from "astro-htmlnano"export const onRequest = getAstroHTMLNano()
```astro-posthtml
> Transform Astro files with PostHTML
## Install
```sh
npm install --save astro-posthtml
```## Usage
### `getAstroPostHTML` (function)
Transform Astro files with PostHTML
**Parameters:**
- plugins (`Plugin[]`) - The posthtml plugins to use when transforming the HTML files
- options (`Options`) - The posthtml options**returns:** (\_context: APIContext, Record>, next: MiddlewareNext) => Promise
Create `./src/middleware.ts` with the following content:
```ts
import { getAstroPostHTML } from "astro-posthtml"
import htmlnano from "htmlnano"export const onRequest = process.env.NODE_ENV === "production" ? getAstroPostHTML([htmlnano()]) : undefined
```## 🤝 Contributing
You can sponsor my work here:
https://github.com/sponsors/aminya
Pull requests, issues and feature requests are welcome.
See the [Contributing guide](https://github.com/aminya/atro-plugins/blob/master/CONTRIBUTING.md).