-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (54 loc) · 1.46 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
var gulp = require('gulp');
// include plug-ins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var htmlhint = require('gulp-htmlhint');
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: './src/'
},
port: 8000
});
});
// JS hint task
gulp.task('jshint', function() {
gulp.src('./src/scripts/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(browserSync.reload({stream: true}));
});
//https://www.browsersync.io/docs/gulp#gulp-reload
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
// Sass task
gulp.task('styles', function() {
gulp.src('./src/styles/sass/**/*.scss')
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(gulp.dest('./src/styles/css/'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('htmlvalidation', function() {
gulp.src('./src/**/*.html')
.pipe(htmlhint())
.pipe(htmlhint.reporter())
.pipe(browserSync.reload({stream: true}));
});
// default gulp task
gulp.task('default', ['browserSync', 'jshint', 'styles', 'htmlvalidation'], function() {
// watch for HTML changes
gulp.watch('./src/**/*.html', function() {
gulp.run('htmlvalidation');
});
// watch for JS changes
gulp.watch('./src/scripts/*.js', function() {
gulp.run('jshint');
});
// watch for CSS changes
gulp.watch('./src/styles/sass/*.scss', function() {
gulp.run('styles');
});
});