forked from JillElaine/jquery-idleTimeout
-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
77 lines (70 loc) · 2.21 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* eslint-disable */
var gulp = require('gulp');
var stripCode = require('gulp-strip-code');
var stripLine = require('gulp-strip-line');
var rename = require("gulp-rename");
var replace = require('gulp-replace');
var uglify = require('gulp-uglify');
var del = require('del');
var cleanCSS = require('gulp-clean-css');
gulp.task('clean', function() {
del('dist/js/*');
return del('dist/css/*');
});
gulp.task('standard', ['clean'], function() {
return gulp.src(['src/jquery-idleTimeout-plus.js'])
.pipe(stripCode({
start_comment: '--strip_testing_begin--',
end_comment: '--strip_testing_end--'
}))
.pipe(stripCode({
start_comment: '--strip_iframe_begin--',
end_comment: '--strip_iframe_end--'
}))
.pipe(stripLine([
/--strip_testing--/,
/--strip_iframe--/,
/console.log/,
/@namespace/,
/eslint-disable-next-line/
]))
.pipe(replace(/({|;)\s*\n\n+(\s*)/g,'$1\n$2'))
.pipe(replace(/({|;)(\s+.*)\n\n+(\s*)/g,'$1$2\n$3'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('iframe', ['clean', 'standard'], function() {
return gulp.src(['src/jquery-idleTimeout-plus.js'])
.pipe(stripCode({
start_comment: '--strip_testing_begin--',
end_comment: '--strip_testing_end--'
}))
.pipe(stripLine([
/--strip_testing--/,
/--strip_iframe_/,
/console.log/,
/@namespace/,
/eslint-disable-next-line/
]))
.pipe(replace(/\s\/\* --strip_iframe--.*/g, ''))
.pipe(replace(/({|;)\s*\n\n+(\s*)/g,'$1\n$2'))
.pipe(replace(/({|;)(\s+.*)\n\n+(\s*)/g,'$1$2\n$3'))
.pipe(rename('jquery-idleTimeout-plus-iframe.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('mini', ['clean', 'standard', 'iframe'], function() {
return gulp.src(['dist/js/*.js'])
.pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('dist/js'))
});
gulp.task('css', ['clean'], function() {
return gulp.src(['src/*.css'])
.pipe(gulp.dest('dist/css'))
});
gulp.task('minicss', ['clean', 'css'], function() {
return gulp.src(['dist/css/*.css'])
.pipe(cleanCSS())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('dist/css'))
});
gulp.task('default', ['clean', 'standard', 'iframe', 'mini', 'css', 'minicss']);