Simple CLI for PostHTML
Install
npm install --global posthtml-cli
Usage
$ 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]
Config
Default read options for plugins from package.json using posthtml-load-plugins
package.json
{
"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"
}
}
}[name].[ext]
JS
module.exports = { bem: { elemPrefix: '__', modPrefix: '-', modDlmtr: '--' }, include: { root: './', encoding: 'utf-8' }, styleToFile: { path: './dist/style.css' } }
JSON
{
"bem": {
"elemPrefix": "__",
"modPrefix": "-",
"modDlmtr": "--"
},
"include": {
"root": "./",
"encoding": "utf-8"
},
"styleToFile": {
"path": "./dist/style.css"
}
}Examples
Sample
$ posthtml -o output.html -i input.htmlOptions config
$ posthtml -o output.html -i input.html -c posthtml.json$ posthtml -o output.html -i input.html -c posthtml.jsOptions use
$ 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
Read dir
$ posthtml -o outputFolder/ -i inputFolder/*.html$ posthtml -o outputFolder/ -i inputFolder/**/*.htmlReplace
$ posthtml -i input.html -r$ posthtml -i inputFolder/*.html -r