Skip to content

Repository files navigation

@metalsmith/minify

A metalsmith plugin to minify HTML,CSS,JSON, and SVG using html-minifier-next, lightningcss and svgo

metalsmith: core pluginnpm: versionci: buildcode coveragelicense: MIT

Installation

NPM:

npm install @metalsmith/minify

Yarn:

yarn add @metalsmith/minify

Usage

Pass @metalsmith/minify to metalsmith.use :

importminifyfrom'@metalsmith/minify'constisDev=process.env.NODE_ENV==='development'metalsmith.use(minify())// defaultsmetalsmith.use(minify({// explicit defaultshtml: {
...minify.htmlPresets.comprehensive,pattern: '**/*.html',conservativeCollapse: false,minifyJS: false,continueOnMinifyError: false,continueOnParseError: false// log is set to @metalsmith/minify:info by default},css: {pattern: '**/*.css',minify: !isDev,sourceMap: isDev},json: false,svg: {pattern: '**/*.svg'}}))

@metalsmith/minify minifies HTML only by ef

Options

Optional section with list or table of options, if the plugin has a lot of options

Specific usage example

Document a first specific usage example, the title can be "Achieve x by doing y"

Specific usage example

Document a second specific usage example, the title can be "Achieve x by doing y"

Debug

To enable debug logs, set the DEBUG environment variable to @metalsmith/minify*:

metalsmith.env('DEBUG','@metalsmith/minify*')

Alternatively you can set DEBUG to @metalsmith/* to debug all Metalsmith core plugins.

CLI usage

To use this plugin with the Metalsmith CLI, add @metalsmith/minify to the plugins key in your metalsmith.json file:

{
"plugins": [
{
"@metalsmith/minify": {}
}
]
}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from metalsmith/core-plugin