index.html
<html>
<head>
<title>index.html</title>
</head>
<body>
<include src="component/button/button.html">
</body>
</html>
component/button/button.html
<button class="button"><div class="button__text">Button</div></button>
var posthtml = require('posthtml'),
html = require('fs').writeFileSync('index.html').toString();
posthtml()
.use(require('posthtml-include')({ encoding: 'utf-8' }))
.process(html)
.then(function(result) {
console.log(result.html);
//<html>
//<head>
// <title>index.html</title>
//</head>
//<body>
// <button class="button"><div class="button__text">Text</div></button>
//</body>
//</html>
})
root: Root folder path for include. Default ./
encoding: Default utf-8