Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rspack-contrib/rsbuild-plugin-html-minifier-terser
An Rsbuild plugin to use `html-minifier-terser` to minify the HTML outputs.
https://github.com/rspack-contrib/rsbuild-plugin-html-minifier-terser
rsbuild rsbuild-plugin rspack
Last synced: 16 days ago
JSON representation
An Rsbuild plugin to use `html-minifier-terser` to minify the HTML outputs.
- Host: GitHub
- URL: https://github.com/rspack-contrib/rsbuild-plugin-html-minifier-terser
- Owner: rspack-contrib
- License: mit
- Created: 2024-07-08T06:50:23.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-12-01T01:43:51.000Z (26 days ago)
- Last Synced: 2024-12-01T02:30:41.179Z (26 days ago)
- Topics: rsbuild, rsbuild-plugin, rspack
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rspack - rsbuild-plugin-html-minifier-terser - minifier-terser` to minify the HTML outputs. (Plugins / Rsbuild Plugins)
README
# rsbuild-plugin-html-minifier-terser
An Rsbuild plugin to use [html-minifier-terser](https://github.com/terser/html-minifier-terser) to minify the HTML outputs.
## Usage
Install:
```bash
npm add rsbuild-plugin-html-minifier-terser -D
```### Basic
Add plugin to your `rsbuild.config.ts`, HTML will be minified by default and JS minimization affected by Rsbuild's config.
```ts
// rsbuild.config.ts
import { pluginHtmlMinifierTerser } from 'rsbuild-plugin-html-minifier-terser'export default {
plugins: [pluginHtmlMinifierTerser()],
}
```### Customize options
The plugin could accept an parameter of type `HtmlMinifierOptions | ((options: HtmlMinifierOptions) => HtmlMinifierOptions)`.
1. Passing options to customize the minification, fields listed in the options will override the default options.
```ts
export default {
plugins: [
pluginHtmlMinifierTerser({
// `minifyCSS` will be set to false
minifyCSS: false,
}),
],
}
```2. A callback function can be passed to the plugin to customize the minification options based on the default options, and the return value will be used as the final options.
```ts
export default {
plugins: [
pluginHtmlMinifierTerser((options) => {
// customize options here
return options
}),
],
}
```## License
[MIT](./LICENSE).