Go to file
MDLeom 4bd000bfee
release: 9.0.0
2024-06-22 02:28:47 +00:00
.github ci: use windows bash 2024-06-11 12:37:53 +00:00
lib feat: zstd compression 2024-06-06 11:14:57 +00:00
test feat: zstd compression 2024-06-06 11:14:57 +00:00
.gitignore feat(ci): run linux jobs using Bun 2023-10-01 04:05:08 +00:00
.npmrc docs: install zstd dependency explicitly 2024-06-11 11:30:02 +00:00
.snyk chore(snyk): remove old policy 2022-05-13 00:50:47 +00:00
LICENSE docs(license): update year 2024-06-10 06:19:21 +00:00
README.md docs: install zstd dependency explicitly 2024-06-11 11:30:02 +00:00
bunfig.toml feat(ci): run linux jobs using Bun 2023-10-01 04:05:08 +00:00
index.js Merge pull request #157 from curbengh/previewServer 2024-06-07 20:06:54 +09:30
package.json release: 9.0.0 2024-06-22 02:28:47 +00:00

README.md

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:
  • enable - Enable the plugin. Defaults to true.
  • previewServer - Disable the plugin when running hexo server. Defaults to true.
  • html - See HTML section
  • css - See CSS section
  • js - See JS section
  • svg - See SVG section
  • gzip - See Gzip section
  • brotli - See Brotli section
  • xml - See XML section
  • json - See JSON section

HTML

minify:
  html:
    enable: true
    exclude:
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10. Set lower value to set higher priority and vice versa.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • globOptions - See globbing section.

For more options, see HTMLMinifier.

CSS

minify:
  css:
    enable: true
    exclude:
      - "*.min.css"
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • level - Optimization level. Defaults to 2.
  • globOptions - See globbing section.

For more options, see clean-css.

JS

minify:
  js:
    enable: true
    exclude:
      - "*.min.js"
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • compress - Compress options.
  • mangle - Mangle variable names. Defaults to true. Pass an object to specify mangle options.
  • output - Output options.
    • To retain comments, output: {comments: true}.
  • globOptions - See globbing section.

For more options, see Terser.

SVG

minify:
  svg:
    enable: true
    include:
      - "*.svg"
      - "!*.min.svg"
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.svg by default.
  • plugins - Plugin options.
    • Examples:
    plugins:
      # Retain comments
      removeComments: false
      # Do not remove unused ID attributes
      cleanupIds: false
    
    • For more options, see svgo.
  • globOptions - See globbing section.

XML

Remove whitespaces in xml.

minify:
  xml:
    enable: false
    include:
      - "*.xml"
      - "!*.min.xml"
  • enable - Enable the plugin. Defaults to false.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.xml by default.
  • removeComments - Remove comments in xml. Defaults to true.
  • globOptions - See globbing section.

For more options, see minify-xml.

JSON

Remove whitespaces in json.

minify:
  json:
    enable: false
    include:
      - "*.json"
      - "!*.min.json"
  • enable - Enable the plugin. Defaults to false.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.json by default.
  • globOptions - See globbing section.

Gzip

minify:
  gzip:
    enable: true
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Support one-liner, include: ['*.html','*.css','*.js'].
    • Must include asterisk and single quotes. .html is invalid. '*.html' is valid.
  • globOptions - See globbing section.
  • level - Compression level; lower value may results in faster compression but slightly larger (compressed) file. Range 1-9. Defaults to 9, or the value of zlib.constants.Z_BEST_COMPRESSION

Brotli

minify:
  brotli:
    enable: true
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
  • globOptions - See globbing section.
  • level - Compression level. Range 1-11. Defaults to 11, or the value of zlib.constants.BROTLI_MAX_QUALITY

Zstd

minify:
  zstd:
    enable: false
    include:
      - "*.html"
      - "*.css"
      - "*.js"
      - "*.txt"
      - "*.ttf"
      - "*.atom"
      - "*.stl"
      - "*.xml"
      - "*.svg"
      - "*.eot"
      - "*.json"
  • enable - Enable the plugin. Defaults to false.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
  • globOptions - See globbing section.
  • level - Compression level. Range 1-22. Defaults to 3, or the value of DEFAULT_LEVEL

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

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

  • @mongodb-js/zstd-darwin-arm64 (Apple Silicon)
  • @mongodb-js/zstd-darwin-x64 (Intel Mac)
  • @mongodb-js/zstd-linux-arm64-gnu
  • @mongodb-js/zstd-linux-arm64-musl (Alpine)
  • @mongodb-js/zstd-linux-x64-gnu
  • @mongodb-js/zstd-linux-x64-musl (Alpine)
  • @mongodb-js/zstd-win32-x64-msvc

Globbing

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

  • basename is enabled by default, unless the pattern has a slash.
  • basename is disabled depending on each pattern.
  • This means the following options would work,
exclude:
  - "*foo.html" # basename is enabled
  - "**/bar/*/*.html" # basename is automatically disabled
  - "*baz.css" # basename is enabled
globOptions:
  basename: true # default
  • This behaviour doesn't apply to pattern that starts with ! (negation).
  • This limitation only applies to include: option used in svg, gzip and brotli.
  • This means the following options would not work,
include:
  - "!foo.svg"
  - "!**/bar/*/*.svg"
globOptions:
  basename: true
  • basename will stay disabled, if explicitly disabled in "globOptions".

Credits

All credits go to the following work: