-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Gulpfile.js
55 lines (47 loc) · 1.71 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
var gulp = require('gulp'),
del = require('del'),
vinylPaths = require('vinyl-paths'),
$ = require('gulp-load-plugins')();
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>',
' * ------------------------',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' * @author <%= pkg.author.name %>',
' * Twitter : @AlexandreDemode',
' * Website : <%= pkg.author.url.replace("http://", "") %>',
' */',
'\n'].join('\n');
var bannerLight = ['/** <%= pkg.title %> v<%= pkg.version %> by <%= pkg.author.name %>',
' - <%= pkg.homepage.replace("http://", "") %>',
' - <%= pkg.license %> License',
' */',
'\n'].join('');
gulp.task('clean', function () {
return gulp.src(['dist/*'])
.pipe(vinylPaths(del));
});
gulp.task('lint', function () {
return gulp.src(['src/cookies-eu-banner.js'])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
});
gulp.task('scripts', function () {
return gulp.src(['src/cookies-eu-banner.js'])
.pipe($.header(banner, { pkg: pkg }))
.pipe($.concat('cookies-eu-banner.js', { newLine: '\r\n\r\n' }))
.pipe(gulp.dest('dist/'))
.pipe($.size({ title: 'cookies-eu-banner.js' }))
.pipe($.rename({ suffix: '.min' }))
.pipe($.uglify())
.pipe($.header(bannerLight, { pkg: pkg }))
.pipe(gulp.dest('dist/'))
.pipe($.size({ title: 'cookies-eu-banner.min.js' }));
});
gulp.task('watch', function () {
gulp.watch(['src/cookies-eu-banner.js'], gulp.series('lint', 'scripts'));
});
gulp.task('build', gulp.series('clean', 'lint', 'scripts'));
gulp.task('test', gulp.series('build'));
gulp.task('default', gulp.series('build', 'watch'));