forked from Alex-D/Cookies-EU-banner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
61 lines (52 loc) · 1.84 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
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 %> - <%= pkg.description %>',
' - <%= pkg.homepage.replace("http://", "") %>',
' - License <%= pkg.license %>',
' - Author : <%= pkg.author.name %>',
' / <%= pkg.author.url.replace("http://", "") %>',
' */',
'\n' ].join('');
gulp.task('clean', function () {
return gulp.src([ '*.min.js' ])
.pipe(vinylPaths(del));
});
gulp.task('test', function () {
return gulp.src([ 'src/cookies-eu-banner.js' ])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
});
gulp.task('scripts', [ 'test' ], 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' ], [ 'scripts' ]);
gulp.watch([ 'dist/**' ], function (file) {
$.livereload.changed(file);
});
$.livereload.listen();
});
gulp.task('build', [ 'scripts' ]);
gulp.task('default', [ 'build', 'watch' ]);