Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

metalsmith/minify

Open more actions menu

Repository files navigation

@metalsmith/minify

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

metalsmith: core plugin npm: version ci: build code coverage license: MIT

Installation

NPM:

npm install @metalsmith/minify

Yarn:

yarn add @metalsmith/minify

Usage

Pass @metalsmith/minify to metalsmith.use :

import minify from '@metalsmith/minify'
const isDev = process.env.NODE_ENV === 'development'

metalsmith.use(minify()) // defaults
metalsmith.use(
  minify({
    // explicit defaults
    html: {
      ...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

Watchers

Forks

Releases

Packages

Contributors

Languages

Generated from metalsmith/core-plugin
Morty Proxy This is a proxified and sanitized view of the page, visit original site.