-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
125 lines (112 loc) · 2.97 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var gulp = require('gulp');
var gulpSequence = require('gulp-sequence');
var ghPages = require('gulp-gh-pages');
var Metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var templates = require('metalsmith-templates');
var collections = require('metalsmith-collections');
var permalinks = require('metalsmith-permalinks');
var sass = require('metalsmith-sass');
var _ = require('lodash');
var metadata = require("./metadata.json");
var browserSync = require('browser-sync').create();
var path = require('path');
var del = require('del');
var metalsmithAssert = function(input){
return function(files, metalsmith, done){
console.log(metalsmith.metadata().collections);
}
}
gulp.task('default', ['server']);
gulp.task('build',
gulpSequence(
'clean',
['build-html', 'build-styles', 'build-js']
)
);
gulp.task('watch', function() {
gulp.watch('./src/styles/**/*.scss', ['build-styles']);
gulp.watch('./src/scripts/**/*.js', ['build-js']);
gulp.watch('./src/content/**/*.md', ['build-html']);
gulp.watch('./src/templates/**/*.jade', ['build-html']);
});
gulp.task('server', ['build', 'watch'], function() {
browserSync.init({
server: { baseDir: "./build" }
});
gulp.watch('./build/**/*.html').on("change", browserSync.reload);
gulp.watch('./build/**/*.js').on("change", browserSync.reload);
gulp.watch('./build/application.css').on("change", browserSync.reload);
});
gulp.task('build-html', function(done){
Metalsmith(__dirname)
.source("src/content")
.clean(false)
.metadata( metadata )
.use(collections({
posts: {
pattern: 'posts/*.md',
sortBy: 'date',
reverse: true
}
}))
.use(markdown())
.use(permalinks({
pattern: ':title-:date',
date: 'YYYY'
}))
.use(templates({
engine: "jade"
, pretty: true
//, inPlace: true
}))
.build(function(err) {
if (err){
console.log(err);
}
console.log("Build finished");
done(err);
});
});
gulp.task('build-styles', function(done){
Metalsmith(__dirname)
.source("src/styles")
.clean(false)
.use(sass({
outputStyle: "expanded",
file: './src/styles/application.scss',
success: function(css){
console.log(css);
},
error: function(error) {
console.log(error);
},
includePaths: [
'./src/styles/bourbon',
'./src/styles/neat',
'./src/styles/base'
]
}))
.build(function(err) {
if (err){
console.log(err);
}
console.log("SASS finished");
done(err);
});
});
gulp.task('build-js', function(){
});
gulp.task('clean', function(done){
return del('./build', done);
});
gulp.task('publish', ['build'], function() {
return gulp.src('./build/**/*')
.pipe(ghPages({
remoteUrl: "[email protected]:bapti/metalsmith-test.git",
origin: "origin",
//branch: "gh-pages",
push: true,
force: true
}));
});