Templating system courtesy of https://github.com/dennib/Bakery.git
HIGHLIGHTS
- Handlebars (with layouts and partials)
- SASS/SCSS/CSS support (with scoped styles)
- Images/File loader
- ES6 to ES5 transpiling with Babel
- HTML and CSS minification
- Easy and fast setup and workflow
-
Clone the repo
-
Install npm packages
npm installIt injects every page template (found in src/views/templates) in the desired layout, main.hbs by default (found in src/views/layouts). You can add as many layouts and templates as you want.
If you want, you can separate reusable parts of your code in their own component file by simply creating the respective .hbs file in src/views/partials and then call them in any of your handlebars templates.
Every page you want to add needs a folder in src/views/templates, and respective .js, .hbs and .scss files inside of it with same name. You can create them by and or simply typing:
npm run create name-of-the-pageThis will create the directory src/views/templates/name-of-the-page with 3 files inside of it:
-
name-of-the.page.scss: a blank and ready to go scss stylesheet for current page. -
name-of-the-page.js: needed as entry point for webpack, by default it only loads respective stylesheet, you can add any javascript code for current page. (Note that every page will receive this chuck and the global onesrc/js/global.js) -
name-of-the-page.hbs: the template itself, by default injected inmain.hbslayout. You can add HTML or Handlebars code as well as use.hbs partials.
- Insert
HTML/Handlebarscode in yourname-of-the.page.hbsfile - Insert
css/scss codespecific to this page inname-of-the.page.scss - Insert global
css/scsscode insrc/scss/main.scss - Create and/or import handlebars
partialsfromsrd/views/partials
(see commands below)
-
npm run create name-of-the-page: Lets you add a new page template. Creates required files as described in Guide. Changename-of-the-pagewith the your new page desired name. -
npm run build: Build the project in thedistfolder, ready forproduction. -
npm run dev: Startwebpack-dev-serverathttp://localhost:8080(with live-reload) -
npm run dev:open: Same asnpm run devbut with browser opened automatically.
In config.js you can find a config.htmlMinifyOptions configuation object with the default HTML minification config included in Bakery:
// HTML Minimizer options
// Set the values you want or add other settings
// among the ones available from
// https://github.com/kangax/html-minifier#options-quick-reference
config.htmlMinifyOptions = {
collapseWhitespace: true,
collapseInlineTagWhitespace: false,
conservativeCollapse: false,
preserveLineBreaks: true,
removeAttributeQuotes: false,
removeComments: false,
useShortDoctype: false,
html5: true,
}
module.exports = configNote: you can add other minification options, find all available ones at HTML Minifier documentation page.