Minify CSS, HTML, and JS files using clean-css
, html-minifier
, and terser
respectively.
As the name suggest this is a hoast module.
Install hoast-minify using npm.
$ npm install --save hoast-minify
css
: Options forclean-css
.- Type:
Object
- Default:
{}
- Default:
- Type:
html
: Options forhtml-minifier
.- Type:
Object
- Default:
{ collapseWhitespace: true, removeComments: true }
- Default:
- Type:
js
: Options forterser
.- Type:
Object
- Default:
{}
- Default:
- Type:
patternsCSS
: Glob patterns to match file paths with that will be processed byclean-css
.- Type:
String
orArray of strings
- Default:
[ '*.css' ]
- Default:
- Type:
patternsHTML
: Glob patterns to match file paths with that will be processed byhtml-minifier
.- Type:
String
orArray of strings
- Default:
[ '*.html' ]
- Default:
- Type:
patternsJS
: Glob patterns to match file paths with that will be processed byterser
.- Type:
String
orArray of strings
- Default:
[ '*.js', '*.mjs' ]
- Default:
- Type:
patternOptions
: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.- Type:
Object
- Default:
{}
- Type:
patternOptions.all
: This options is added topatternOptions
, and determines whether all patterns need to match instead of only one.- Type:
Boolean
- Default:
false
- Type:
The
css
andjs
options will also be given to thehtml-minifier
to use for CSS and JS content within HTML files.
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();