-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
48 lines (43 loc) · 1.19 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var header = require('gulp-header');
var rename = require('gulp-rename');
var del = require('del');
var pkg = require('./package.json');
// Config
var config = {
src: 'src/',
dist: 'dist/'
};
// Banner
var banner = [
'/*!',
' * <%= pkg.name %> v<%= pkg.version %>',
' * <%= pkg.title %>',
' * <%= pkg.homepage %>',
'',
' * Copyright (c) 2016, <%= pkg.author.name %>',
' * Released under the <%= pkg.license.name %> license.',
' */',
''
].join('\n');
// Clean task
gulp.task('clean', function(cb) {
del(['dist/*.js'], cb);
});
// Default task
gulp.task('default', function() {
return gulp.src(config.src + '*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest(config.dist))
.pipe(rename({suffix: '.min'}))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(config.dist));
});
// Watch task
gulp.task('watch', function() {
gulp.watch(config.src + '*.js', ['default']);
});