Utility script to build HTML documents - Appends scripts and styles, removes debug parts, append HTML partials, template options, etc.
npm install html-buildbash
$ npm install html-build --save-dev
`
Usage
$3
Add your build script to your package.json scripts:
`json
{
//...
"scripts": {
"build-html": "html-build -c config.js index.html samples/"
}
//...
}
`
Create a configuration file ([more informations][doc-options]):
`javascript
module.exports = {
beautify: true,
prefix: "//some-cdn",
relative: true,
basePath: false,
scripts: {
bundle: [
"scripts/*.js",
"!**/main.js",
],
main: "scripts/main.js"
},
styles: {
bundle: [
"css/libs.css",
"css/dev.css"
],
test: "css/inline.css"
},
sections: {
views: "views/*/.html",
templates: "templates/*/.html",
layout: {
header: "layout/header.html",
footer: "layout/footer.html"
}
},
data: {
// Data to pass to templates
version: "0.1.0",
title: "test",
}
};
`
Then run your script:
`bash
$ npm run build-html
`
$3
`javascript
var htmlBuild = require("html-build");
htmlBuild.build("index.html", "samples/", { / config / });
`
Exemple
Using the configuration above, consider the following example html to see it in action:
`html
grunt-html-build - Test Page
`
After running the grunt task it will be stored on the samples folder as
`html
grunt-html-build - Test Page
...
...
...
...
``