Simple CLI for PostHTML
npm install --global posthtml-cli
$ posthtml --help
Usage
posthtml [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config] [--use|-u plugin]
Options
--config, -c Path to JSON file [string]
--output, -o Output html file/folder result [required]
--input, -i Input html file/folder [required]
--use, -u Posthtml plugin name [string]
--replace, -r Replace input file(s) [boolean]
--help, -h Show help [boolean]
--version, -v Show version number [boolean]
Default read options for plugins from package.json using posthtml-load-plugins
{
"name": "my project",
"dependencies": {
"posthtml-bem": "^0.2.2",
"posthtml-each": "^1.0.1",
"posthtml-include": "^1.0.2"
},
"devDependencies": {
"posthtml-style-to-file": "^0.1.1"
},
"posthtml": {
"bem": {
"elemPrefix": "__",
"modPrefix": "-",
"modDlmtr": "--"
},
"include": {
"root": "./",
"encoding": "utf-8"
},
"styleToFile": {
"path": "./dist/style.css"
}
}
}
module.exports = {
bem: {
elemPrefix: '__',
modPrefix: '-',
modDlmtr: '--'
},
include: {
root: './',
encoding: 'utf-8'
},
styleToFile: {
path: './dist/style.css'
}
}
{
"bem": {
"elemPrefix": "__",
"modPrefix": "-",
"modDlmtr": "--"
},
"include": {
"root": "./",
"encoding": "utf-8"
},
"styleToFile": {
"path": "./dist/style.css"
}
}
$ posthtml -o output.html -i input.html
$ posthtml -o output.html -i input.html -c posthtml.json
$ posthtml -o output.html -i input.html -c posthtml.js
$ posthtml
-o output.html
-i input.html
-c config.json
-u posthtml-bem
--posthtml-bem.elemPrefix __
--posthtml-bem.elemMod _
-u posthtml-css-modules
--posthtml-css-modules path/to/json
-u posthtml-custom-elements
$ posthtml -o outputFolder/ -i inputFolder/*.html
$ posthtml -o outputFolder/ -i inputFolder/**/*.html
$ posthtml -i input.html -r
$ posthtml -i inputFolder/*.html -r