-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
52 lines (44 loc) · 1.23 KB
/
gulpfile.js
File metadata and controls
52 lines (44 loc) · 1.23 KB
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
'use strict';
// imports
const gulp = require('gulp');
const htmlbeautify = require('gulp-html-beautify');
const less = require('gulp-less');
const autoprefixer = require('gulp-autoprefixer');
const bs = require('browser-sync').create(); // create a browser sync instance.
const eslint = require('gulp-eslint');
// paths
const htmlSources = './*.html';
const cssSources = 'assets/styles/*.less';
gulp.task('browser-sync', function() {
bs.init({
server: {
baseDir: './',
},
});
});
gulp.task('less', function () {
return gulp.src(cssSources)
.pipe(less())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false,
}))
.pipe(gulp.dest('assets/styles'));
});
gulp.task('htmlbeautify', function() {
gulp.src('./*.html')
.pipe(htmlbeautify({ indentSize: 2 }))
.pipe(gulp.dest('./'));
});
gulp.task('lint', function () {
return gulp.src(['js/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('watch', function() {
gulp.watch(cssSources, ['less']).on('change', bs.reload);
gulp.watch(htmlSources, ['htmlbeautify']).on('change', bs.reload);
gulp.watch('js/**/*.js', ['lint']);
});
gulp.task('default', ['browser-sync', 'lint', 'watch']);