-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (75 loc) · 1.99 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
'use strict';
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var eslint = require('gulp-eslint');
var babel = require('gulp-babel');
var del = require('del');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var notifier = require('node-notifier');
var plumber = require('gulp-plumber');
gulp.task('compile', ['js']);
gulp.task('compile:js', function() {
return gulp.src([
'./src/jquery-match-heights.js'
], { base: './' })
.pipe(sourcemaps.init())
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(babel({
presets: ['env']
}))
.pipe(rename(function (path) {
path.dirname = '';
return path;
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('lint', ['lint:js']);
gulp.task('lint:js', function () {
return gulp.src([
'./src/jquery-match-heights.js'
])
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('js', function() {
return gulp.src('./src/jquery-match-heights.js')
.pipe(sourcemaps.init())
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(babel({
presets: ['env']
}))
.pipe(concat('jquery-match-heights.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('clean', ['clean:js']);
gulp.task('clean:js', function () {
return del([
'./dist/*'
], {force: true});
});
gulp.task('watch', function() {
gulp.watch([
'./src/jquery-match-heights.js'
], ['lint:js', 'js']).on('change', function() {
notifier.notify({
title: 'Watch',
message: 'running tasks...'
});
});
});
gulp.task('default', function(callback) {
runSequence(
'clean',
'compile',
'lint',
function() {
notifier.notify({ title: 'Build', message: 'Done' });
callback();
}
);
});