-
Notifications
You must be signed in to change notification settings - Fork 121
/
gulpfile.babel.js
90 lines (82 loc) · 2.52 KB
/
gulpfile.babel.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
86
87
88
89
'use strict';
import gulp from 'gulp';
import sass from 'gulp-sass';
import cleanCSS from 'gulp-clean-css';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
import autoprefixer from 'gulp-autoprefixer';
import uglify from 'gulp-uglify';
import jshint from 'gulp-jshint';
import saveLicense from 'uglify-save-license';
let pkg = require('./package.json'),
version = pkg.version,
date = new Date(),
yyyy = date.getFullYear().toString(),
mm = (date.getMonth()+1).toString(),
dd = date.getDate().toString(),
yyyymmdd = `${yyyy}-${mm}-${dd}`,
banner = `/*!
* jQuery Typeahead
* Copyright (C) ${yyyy} RunningCoder.org
* Licensed under the MIT license
*
* @author ${pkg.author.name}
* @version ${version} (${yyyymmdd})
* @link http://www.runningcoder.org/jquerytypeahead/
*/
`;
gulp.task('scss', function () {
return gulp.src('./src/jquery.typeahead.scss')
.pipe(sass({
outputStyle: 'expanded'
}))
.pipe(autoprefixer({
browsers: [
'last 3 versions',
'ie >= 8',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
],
cascade: false
}))
.pipe(gulp.dest('./src'))
.pipe(cleanCSS())
.pipe(rename('jquery.typeahead.min.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('jshint', function() {
return gulp.src('./src/jquery.typeahead.js')
.pipe(jshint({
shadow: true,
expr: true,
loopfunc: true,
// Switch statements "falls through"
"-W086": true,
validthis: true,
scripturl:true
}))
.pipe(jshint.reporter('default'));
});
gulp.task('js', function () {
return gulp.src('./src/jquery.typeahead.js')
.pipe(replace(/\/\*![\S\s]+?\*\/[\r\n]*/, banner))
.pipe(replace(/version: ["'].*?["']/, `version: '${version}'`))
.pipe(gulp.dest('./src'))
.pipe(rename('jquery.typeahead.min.js'))
.pipe(replace(/\/\/\s?\{debug}[\s\S]*?\{\/debug}/g, ''))
.pipe(uglify({
mangle: true,
//preserveComments: 'license'
output: {
comments: saveLicense
}
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function () {
gulp.watch('./src/jquery.typeahead.scss', gulp.task('scss')).on('change', function (file) {
console.log(file)
});
});
gulp.task('default', gulp.parallel('scss', /*'jshint',*/ 'js'));