forked from unrealevil/jquery-idleTimeout-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (74 loc) · 2.35 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
78
79
80
81
/* 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');
var once = require('async-once');
gulp.task('clean', once(function(done) {
del('dist/js/*');
del('dist/css/*');
return done();
}));
gulp.task('standard', gulp.series('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', gulp.series('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', gulp.series('clean', 'standard', 'iframe', function() {
return gulp.src(['dist/js/*.js'])
.pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('dist/js'))
}));
gulp.task('css', gulp.series('clean', function() {
return gulp.src(['src/*.css'])
.pipe(gulp.dest('dist/css'))
}));
gulp.task('minicss', gulp.series('clean', 'css', function() {
return gulp.src(['dist/css/*.css'])
.pipe(cleanCSS())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('dist/css'))
}));
gulp.task('default', gulp.series('clean', 'standard', 'iframe', 'mini', 'css', 'minicss', function (done) {
done();
}));