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 install
It 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-page
This 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.hbs
layout. You can add HTML or Handlebars code as well as use.hbs partials
.
- Insert
HTML/Handlebars
code in yourname-of-the.page.hbs
file - Insert
css/scss code
specific to this page inname-of-the.page.scss
- Insert global
css/scss
code insrc/scss/main.scss
- Create and/or import handlebars
partials
fromsrd/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-page
with the your new page desired name. -
npm run build
: Build the project in thedist
folder, ready forproduction
. -
npm run dev
: Startwebpack-dev-server
athttp://localhost:8080
(with live-reload) -
npm run dev:open
: Same asnpm run dev
but 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 = config
Note: you can add other minification options, find all available ones at HTML Minifier documentation page.