curbengh / hexo-yam

Yet Another Minifier. Minify static web assets and compress using brotli and zstd.
MIT License
24 stars 2 forks source link
hexo hexo-plugin minify

hexo-yam

npm version Build Status codecov NPM Dependencies Known Vulnerabilities

Yet Another Minifier for Hexo. Minify HTML, JS, CSS, SVG, XML and JSON. Compress static web assets using gzip, brotli and zstd.

Table of contents

Installation

$ npm install --save hexo-yam

Options

minify:
  enable: true
  previewServer: true
  html:
  css:
  js:
  svg:
  gzip:
  brotli:
  xml:
  json:

HTML

minify:
  html:
    enable: true
    exclude:

For more options, see HTMLMinifier.

CSS

minify:
  css:
    enable: true
    exclude:
      - "*.min.css"

For more options, see clean-css.

JS

minify:
  js:
    enable: true
    exclude:
      - "*.min.js"

For more options, see Terser.

SVG

minify:
  svg:
    enable: true
    include:
      - "*.svg"
      - "!*.min.svg"

XML

Remove whitespaces in xml.

minify:
  xml:
    enable: false
    include:
      - "*.xml"
      - "!*.min.xml"

For more options, see minify-xml.

JSON

Remove whitespaces in json.

minify:
  json:
    enable: false
    include:
      - "*.json"
      - "!*.min.json"

Gzip

minify:
  gzip:
    enable: true
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"

Brotli

minify:
  brotli:
    enable: true
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"

Zstd

minify:
  zstd:
    enable: false
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"

Cannot find module '@mongodb-js/zstd-linux-x64-gnu'

npm install --save @mongodb-js/zstd-linux-x64-gnu

Globbing

Use "globOptions" to customise how glob patterns match files. Refer to micromatch for available options.

exclude:
  - "*foo.html" # basename is enabled
  - "**/bar/*/*.html" # basename is automatically disabled
  - "*baz.css" # basename is enabled
globOptions:
  basename: true # default
include:
  - "!foo.svg"
  - "!**/bar/*/*.svg"
globOptions:
  basename: true

Credits

All credits go to the following work: