-
Notifications
You must be signed in to change notification settings - Fork 89
/
gulpfile.js
38 lines (32 loc) · 995 Bytes
/
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
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var gutil = require('gulp-util');
var notify = require('gulp-notify');
var uglify = require('gulp-uglify');
var eslint = require('gulp-eslint');
var rename = require('gulp-rename');
var files = 'src/*.js';
gulp.task('uglify', function() {
return gulp.src(files)
.pipe(plumber())
.pipe(uglify({preserveComments: 'license'}))
.on('error', notify.onError('Error: <%= error.message %>'))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('lint', function() {
return gulp.src(files)
.pipe(plumber())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.on('error', notify.onError('Error: <%= error.message %>'));
});
gulp.task('copy', function() {
return gulp.src(files)
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['lint', 'uglify', 'copy']);
gulp.task('default', ['build'], function() {
return gulp.watch(files, ['build']);
});