-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·53 lines (41 loc) · 1.35 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
const gulp = require('gulp'),
browserSync = require('browser-sync').create();
sass = require('gulp-sass');
nunjucksRender = require('gulp-nunjucks-render');
const PATHS = {
templates: 'src/templates',
pages: 'src/pages',
scss: 'src/scss',
output: 'docs',
}
// writing up the gulp nunjucks task
gulp.task('nunjucks', function() {
console.log('Rendering nunjucks files..');
return gulp.src(PATHS.pages + '/**/*.+(njk|html)')
.pipe(nunjucksRender({
path: [PATHS.templates],
watch: true,
}))
.pipe(gulp.dest(PATHS.output));
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: PATHS.output
},
});
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src([PATHS.scss + '/*.scss'])
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest(PATHS.output + '/css'))
.pipe(browserSync.stream());
});
// Static Server + watching scss/html files
gulp.task('serve', function() {
gulp.watch([PATHS.pages + '/**/*.+(njk|html)', PATHS.templates + '/**/*.+(njk|html)'], ['nunjucks'])
gulp.watch([PATHS.scss + '/*.scss'], ['sass'])
gulp.watch(PATHS.output + '/*').on('change', browserSync.reload);
});
gulp.task('default', ['browserSync', 'serve']);