-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
executable file
·83 lines (70 loc) · 1.98 KB
/
gulpfile.babel.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
'use strict';
import path from 'path';
import gulp from 'gulp';
import runSequence from 'run-sequence';
import browserSync from 'browser-sync';
import gulpLoadPlugins from 'gulp-load-plugins';
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
var ghPages = require('gulp-gh-pages');
var data = require('gulp-data');
// Compile and automatically prefix stylesheets
gulp.task('styles', () => {
const AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
return gulp.src([
'source/scss/**/*.scss',
'source/scss/**/*.css'
])
.pipe($.sass({
precision: 10
}).on('error', $.sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
// Concatenate and minify styles
.pipe($.size({title: 'styles'}))
.pipe(gulp.dest('dist/styles'));
});
// Scan your HTML for assets & optimize them
gulp.task('html', () => {
return gulp.src('source/templates/**/*.+(html|njk)')
.pipe(data(function() {
return require('./source/data.json')
}))
.pipe($.nunjucksRender({
path: ['source/templates/'] // String or Array
}))
.pipe($.size({title: 'html', showFiles: true}))
.pipe(gulp.dest('dist'));
});
// Scan your images folder for assets and minify them
gulp.task('images', () => {
return gulp.src('source/images/**/*.+(png|jpg|gif|svg)')
// .pipe($.imagemin({
// path: ['source/images']
// }))
.pipe(gulp.dest('dist/images'))
});
// Watch files for changes & reload
gulp.task('default', ['styles', 'html', 'images'], () => {
browserSync({
notify: false,
server: ['dist'],
port: 3000
});
gulp.watch(['source/templates/**/*.+(html|njk)'], ['html', reload]);
gulp.watch(['source/scss/**/*.{scss,css}'], ['styles', reload]);
gulp.watch(['source/images/**/*'], reload);
});
gulp.task('deploy', function() {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});