Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Latest commit

 

History

History
81 lines (62 loc) · 3.13 KB

README.md

File metadata and controls

81 lines (62 loc) · 3.13 KB

npm package @latest npm package @next

Travis-ci status CodeCov coverage

License agreement Open issues on GitHub

hoast-minify

Minify CSS, HTML, and JS files using clean-css, html-minifier, and terser respectively.

As the name suggest this is a hoast module.

Usage

Install hoast-minify using npm.

$ npm install --save hoast-minify

Parameters

  • css: Options for clean-css.
    • Type: Object
      • Default: {}
  • html: Options for html-minifier.
    • Type: Object
      • Default: { collapseWhitespace: true, removeComments: true }
  • js: Options for terser.
    • Type: Object
      • Default: {}
  • patternsCSS: Glob patterns to match file paths with that will be processed by clean-css.
    • Type: String or Array of strings
      • Default: [ '*.css' ]
  • patternsHTML: Glob patterns to match file paths with that will be processed by html-minifier.
    • Type: String or Array of strings
      • Default: [ '*.html' ]
  • patternsJS: Glob patterns to match file paths with that will be processed by terser.
    • Type: String or Array of strings
      • Default: [ '*.js', '*.mjs' ]
  • patternOptions: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.
    • Type: Object
    • Default: {}
  • patternOptions.all: This options is added to patternOptions, and determines whether all patterns need to match instead of only one.
    • Type: Boolean
    • Default: false

The css and js options will also be given to the html-minifier to use for CSS and JS content within HTML files.

Examples

CLI

{
  "modules": {
    "read": {},
    "hoast-minify": {}
  }
}

Script

const Hoast = require(`hoast`);
const read = Hoast.read,
      minify = require(`hoast-minify`);

Hoast(__dirname)
  .use(read())
  .use(minify())
  .process();