-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
57 lines (50 loc) · 1.54 KB
/
gulpfile.js
File metadata and controls
57 lines (50 loc) · 1.54 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
53
54
55
56
57
"use strict";
const gulp = require('gulp');
const plumber = require('gulp-plumber');
// sass
const sass = require('gulp-sass');
const combineMq = require('gulp-combine-mq');
const sassGlob = require("gulp-sass-glob");
// babel
const babelify = require('babelify');
// browserify
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const notify = require('gulp-notify');
const eslint = require('gulp-eslint');
gulp.task('sass', function() {
return gulp.src('src/scss/style.scss')
.pipe(sassGlob())
.pipe(sass({
outputStyle: 'expanded'
})).on('error', sass.logError)
.pipe(combineMq({
beautify: true
}))
.pipe(gulp.dest('./src/css/'));
});
gulp.task('browserify', function () {
return browserify('./src/js/main.js')
.transform(babelify, {presets: ['es2015']})
.bundle()
.on('error', function(err){
console.log(err.message);
console.log(err.stack);
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./js/'));
});
gulp.task('lint', function(){
return gulp.src('./src/js/*.js')
.pipe(plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
}))
.pipe(eslint({useEslintrc: true}))
.pipe(eslint.format())
.pipe(eslint.failOnError())
.pipe(plumber.stop());
});
gulp.task('watch', gulp.series(gulp.task('sass'), function () {
gulp.watch('src/scss/**/*.scss', gulp.task('sass'));
gulp.watch('src/js/**/*.js', gulp.task('browserify'));
}));