This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
forked from weareoutman/clockpicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (66 loc) · 1.58 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
minifyCSS = require('gulp-minify-css'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
qunit = require('gulp-qunit'),
replace = require('gulp-replace'),
// Replace package.version
version = require('./package').version,
versionRegExp = /\{package\.version\}/;
// Rename and uglify scripts
function js(prefix) {
gulp.src('src/clockpicker.js')
.pipe(rename({
prefix: prefix + '-'
}))
.pipe(replace(versionRegExp, version))
.pipe(gulp.dest('dist'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
}
// Rename, concat and minify stylesheets
function css(prefix) {
var stream;
if (prefix === 'bootstrap') {
stream = gulp.src('src/clockpicker.css');
} else {
// Concat with some styles picked from bootstrap
stream = gulp.src(['src/standalone.css', 'src/clockpicker.css'])
.pipe(concat('clockpicker.css'));
}
stream.pipe(rename({
prefix: prefix + '-'
}))
.pipe(replace(versionRegExp, version))
.pipe(gulp.dest('dist'))
.pipe(minifyCSS({
keepSpecialComments: 1
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
}
gulp.task('js', function() {
js('bootstrap');
js('jquery');
});
gulp.task('css', function() {
css('bootstrap');
css('jquery');
});
gulp.task('watch', function() {
gulp.watch('src/*.js', ['js']);
gulp.watch('src/*.css', ['css']);
});
gulp.task('test', function() {
return gulp.src('test/*.html')
.pipe(qunit());
});
gulp.task('default', ['js', 'css', 'watch']);