Load Options
Autoload Options for PostHTML
Install
npm i -D posthtml-load-options
Usage
package.json
Create a posthtml
section in package.json
.
Root
|– client
|– public
|
|- package.json
.posthtmlrc
Create a .posthtmlrc
file.
Root
|– client
|– public
|
|-.posthtmlrc
|- package.json
posthtml.config.js
Create a posthtml.config.js
file.
Root
|– client
|– public
|
|- posthtml.config.js
|- package.json
module { return parser: ctxext ==='.sml' ? 'posthtml-sugarss' : false from: 'path/to/src/file.html' to: 'path/to/dest/file.html' }
Options
parser
:
parser: 'posthtml-sugarss'
from
:
from: 'path/to/dest/file.html'
to
:
to: 'path/to/dest/file.html'
render
:
render: 'posthtml-jsx'
Context
When using a function in (posthtml.config.js)
, it's possible to pass context to posthtml-load-options
, which will be evaluated before loading your options. By default ctx.env (process.env.NODE_ENV)
and ctx.cwd (process.cwd())
are available.
Example
posthtml.config.js
= { return parser: ctxext === '.sml' ? 'posthtml-sugarml' : false from: 'client/index.html' to: 'public/index.html' }
const sml = const ctx = ext: )
Maintainer
Michael Ciniawsky |