-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
63 lines (55 loc) · 1.49 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
var browserSync = require('browser-sync'),
gulp = require('gulp'),
concat = require('gulp-concat'),
path = require('path'),
sass = require('gulp-sass'),
imagemin = require('gulp-imagemin'),
inlinesource = require('gulp-inline-source'),
inlineCss = require('gulp-inline-css');
/**
* Used this function to prevent errors from exiting the watch proccess
*/
function swallowError (error) {
console.log(error.toString());
this.emit('end');
}
gulp.task('serve', ['sass', 'inline'], function() {
browserSync.init({
server: {
baseDir: "./build"
}
});
gulp.watch('./src/img/*', ['images']);
gulp.watch('./src/scss/**/*.scss', ['sass']);
gulp.watch('./src/css/**/*.css', ['inline']);
gulp.watch('./src/**/*.html', ['inline']);
});
/**
* Styles
*/
gulp.task('sass', function () {
return gulp.src('./src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./src/css'));
});
gulp.task('inline', function () {
gulp.src('./src/**/*.html')
.pipe(inlinesource({
compress: false
}))
.pipe(gulp.dest('./dist'))
.pipe(inlineCss({
preserveMediaQueries: true
}))
.pipe(gulp.dest('./build'))
.pipe(browserSync.stream());
});
/**
* Images
*/
gulp.task('images', function () {
gulp.src('./src/img/*')
.pipe(imagemin())
.pipe(gulp.dest('build/img'))
});
gulp.task('default', ['serve']);