-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
100 lines (93 loc) · 2.57 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
/**
* Definitions
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),
filter = require('gulp-filter'),
browsersync = require('browser-sync'),
bsreload = browsersync.reload,
sass = require('gulp-ruby-sass'),
changed = require('gulp-changed'),
autoprefixer = require('gulp-autoprefixer'),
svgstore = require('gulp-svgstore'),
svgmin = require('gulp-svgmin'),
fileinclude = require('gulp-file-include'),
imagemin = require('gulp-imagemin');
/**
* Gulp.js Default
*/
gulp.task('default', ['fileinclude', 'sass', 'svgstore', 'imagemin', 'browser-sync'], function() {
gulp.watch('_sass/**/*.scss', ['sass']);
gulp.watch('_svg/**/*.svg', ['svgstore']);
gulp.watch('_pages/**/*.html', ['fileinclude']);
gulp.watch('_includes/**', ['fileinclude']);
gulp.watch('_images/**', ['imagemin']);
gulp.watch('_site/css/global.css', ['fileinclude']);
gulp.watch('_site/*.html', ['bs-reload']);
});
/**
* SASS Processing
*/
gulp.task('sass', function() {
return sass('_sass/global.scss', {style: 'compressed'})
// .pipe(changed('_site/css'))
.on('error', function(err) {
console.error('Error', err.message);
notify.onError().apply(this, arguments);
this.emit('end');
})
.pipe(autoprefixer())
.pipe(gulp.dest('_site/css'))
.pipe(filter('**/*.css'))
.pipe(bsreload({stream: true}))
});
/**
* SVG Processing
*/
gulp.task('svgstore', function() {
return gulp.src('_svg/*.svg')
.pipe(svgmin())
.pipe(svgstore({
fileName: 'svg-defs.svg',
prefix: 'shape-',
inlineSvg: true,
transformSvg: function (svg, cb) {
svg.attr({ style: 'display:none' });
cb(null);
}
}))
.pipe(gulp.dest('_includes'))
.pipe(bsreload({stream: true}))
});
/**
* File Inclusions
*/
gulp.task('fileinclude', function() {
return gulp.src('_pages/*.html')
.pipe(fileinclude())
.pipe(gulp.dest('_site'))
.pipe(bsreload({stream: true}))
});
/**
* Image Optimisations
*/
gulp.task('imagemin', function() {
return gulp.src('_images/*')
.pipe(imagemin({
progressive: true
}))
.pipe(gulp.dest('_site/images'));
})
/**
* BrowserSync
*/
gulp.task('browser-sync', function() {
browsersync({
server: {
baseDir: "_site"
}
});
});
gulp.task('bs-reload', function() {
browsersync.reload();
});