minify-tag
Minifier of js, css, html.
It is a wrapper for the gorgeous node-minify.
You can use it programmatic as script or as CLI.
Advantage / Motivation: Instead of separate mapping files and html code the needed informations can be set with help of html comments:
<!-- node-minify-tag-glob( {"htmlOut": "_index1.prod.html"} ) --> ... index1 ... <!-- node-minify-tag( {"fileOut":"_abc1.min.css", "type": "no-compress"} ) --> <!-- node-minify-tag-end -->...<!-- node-minify-tag( {"fileOut":"_abc.min.js", "type": "no-compress"} ) --><!-- node-minify-tag-end -->...
Usage
:
As scriptvar minifyTag = ; // HTML in and out file are explicitly specified: // No need for 'node-minify-tag-glob' tag:minifyTag; // Glob mode: // minifyByGlob walk through the sub directories // and looks for all file matching 'filePattern'.// The 'htmlOut' file for each 'htmlIn' must be specified // in an 'node-minify-tag-glob' comment tagminifyTag;
HTML comment attributes
Comment tag | Corresponding comment tag | Options |
---|---|---|
node-minify-tag( options ) | node-minify-tag-end | see below |
node-minify-tag-glob( options ) | none | {"htmlOut": "sample.prod.html"} |
Options node-minify-tag
Key | Possible values | Action | File type |
---|---|---|---|
type | 'no-compress' | concatenation of files | JS / CSS |
type | 'gcc' | Google Closure Compiler | JS |
type | 'yui-js' | YUI Compressor | JS |
type | 'yui-css' | YUI Compressor | CSS |
type | 'uglifyjs' | UglifyJS | JS |
type | 'sqwish' | Sqwish | CSS |
type | 'clean-css' | Clean-css | CSS |
type | 'csso' | CSSO | CSS |
fileOut | name of generated (compressed) html or CSS file | - | - |
Options node-minify-tag-glob
Key | Possible values | Example |
---|---|---|
htmlOut | name of generated html file | 'index.prod.html' |
As CLI
node node_modules/node-minify-tag/index.js -h
// Explicit mode:
node node_modules/node-minify-tag/index.js -d test/demo/ -i abc.html -o __abc.prod.html
// glob mode:
node node_modules/node-minify-tag/index.js -g -d test/demo/ -p **/*.dev.html
Information about glob file pattern can be found here: Glob Primer.