This repository has been archived by the owner on Dec 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
gulpfile.js
70 lines (63 loc) · 1.68 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
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var clean = require('gulp-clean-css');
var rename = require('gulp-rename');
var stylus = require('gulp-stylus');
var fs = require('fs');
var deploy = require('./lib/deploy.js');
/**
* Generates the standard works-for-everyone CSS files that get committed.
*/
gulp.task('dark', function () {
return gulp.src('src/dark.styl')
.pipe(stylus())
.pipe(autoprefixer({
browsers: ['last 2 versions', 'ie 8', 'ie 9'],
cascade: false,
remove: false
}))
.pipe(gulp.dest('dist'))
.pipe(rename('dark.min.css'))
.pipe(clean({
compatibility: 'ie8'
}))
.pipe(gulp.dest('dist'));
});
/**
* This generates a custom build that shouldn't be in source control. Only runs
* if src/custom.styl exists.
*/
gulp.task('custom', function (done) {
if (fs.existsSync('src/custom.styl')) {
return gulp.src('src/custom.styl')
.pipe(stylus())
.pipe(autoprefixer({
browsers: ['last 2 versions', 'ie 8', 'ie 9'],
cascade: false,
remove: false
}))
.pipe(gulp.dest('dist'))
.pipe(rename('custom.min.css'))
.pipe(clean({
compatibility: 'ie8'
}))
.pipe(gulp.dest('dist'));
}
done();
});
gulp.task('watch', function () {
gulp.watch('src/dark*', gulp.series('dark'));
});
gulp.task('watch:deploy', function () {
gulp.watch('src/dark*', gulp.series('deploy'));
});
/**
* Deploys the generated CSS file to Rocket.Chat.
*/
gulp.task('deploy', gulp.series('dark', 'custom', function (done) {
var file = fs.existsSync('src/custom.styl') ? 'custom.css' : 'dark.css';
deploy(__dirname + '/dist/' + file, function (error) {
done(error);
});
}));
gulp.task('default', gulp.series('dark', 'custom'));