Skip to content

Instantly share code, notes, and snippets.

@dotmh
Last active February 7, 2018 14:41
Show Gist options
  • Save dotmh/7b17c61bcfce80ee433ac251c4f9d4d0 to your computer and use it in GitHub Desktop.
Save dotmh/7b17c61bcfce80ee433ac251c4f9d4d0 to your computer and use it in GitHub Desktop.
Metalsmith
var Metalsmith = require('metalsmith');
var Layouts = require('metalsmith-layouts');
var Sass = require('metalsmith-sass');
var Copy = require("metalsmith-copy");
var Watch = require("metalsmith-watch");
var DiscoverPartials = require('metalsmith-discover-partials');
var SRC = "./src";
var VIEWS = SRC+'/_views';
var OUT = "build";
Metalsmith(__dirname)
.source(SRC)
.destination(OUT)
.ignore(['_scss', '_views'])
.clean(true)
.use(DiscoverPartials({
directory : './partials',
pattern: '/\.hbs$/'
}))
.use(Layouts({
pattern: "**/*.html",
directory : VIEWS+'/layouts'
}))
.use(Sass({
outputDir: 'assets/css'
}))
.use(Copy({
pattern: 'assets/*',
directory: 'assets'
})).
use(Watch({
paths : {"${source}/**/*": true}
}))
.build(function(err, files){
if(err) {
throw err;
}
})
./src
├── _sass
│   └── main.scss
├── _views
│   └── layouts
│   └── layout.hbs
├── assets
│   ├── css
│   ├── img
│   │   └── background.jpg
│   └── js
│   └── timezz.min.js
├── index.html
└── partials
└── footer.hbs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment