forked from botui/botui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
executable file
·82 lines (72 loc) · 2.39 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
82
var fs = require('fs'),
gulp = require('gulp'),
sass = require('gulp-sass'),
banner = require('gulp-banner'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
pkg = require('./package.json'),
htmlclean = require('htmlclean'),
replace = require('gulp-replace'),
minify = require('gulp-clean-css');
function escape (text) {
return text.replace(/'/g, "\\'").replace(/"/g, "\\\"");
}
function htmlTemplate() {
return replace('BOTUI_TEMPLATE', escape(
htmlclean(fs.readFileSync('./src/botui.html', 'utf8'))
));
}
var comment = '/*\n' +
' * <%= pkg.name %> <%= pkg.version %>\n' +
' * <%= pkg.description %>\n' +
' * <%= pkg.homepage %>\n' +
' *\n' +
' * Copyright <%= year %>, <%= pkg.author.name %>\n' +
' * Released under the <%= pkg.license %> license.\n' +
'*/\n\n';
gulp.task('styles', function() {
gulp.src(['./src/styles/normal.scss',
'./src/styles/botui.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(minify())
.pipe(concat('botui.min.css'))
.pipe(banner(comment, {
pkg: pkg,
year: new Date().getFullYear()
}))
.pipe(gulp.dest('./build/'));
});
gulp.task('themes', function() {
gulp.src('./src/styles/themes/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minify())
.pipe(rename(function (path) {
path.basename = 'botui-theme-' + path.basename;
}))
.pipe(gulp.dest('./build/'));
});
gulp.task('scripts', function () {
gulp.src('./src/scripts/botui.js') // simply copy the original one
.pipe(htmlTemplate())
.pipe(banner(comment, {
pkg: pkg,
year: new Date().getFullYear()
}))
.pipe(gulp.dest('./build/'));
gulp.src('./src/scripts/botui.js') // minified version
.pipe(uglify())
.pipe(htmlTemplate())
.pipe(rename('botui.min.js'))
.pipe(banner(comment, {
pkg: pkg,
year: new Date().getFullYear()
}))
.pipe(gulp.dest('./build/'));
});
gulp.task('watch',function() {
gulp.watch('./src/styles/*.scss', ['styles']);
gulp.watch('./src/styles/themes/*.scss', ['themes']);
gulp.watch(['./src/scripts/botui.js', './src/botui.html'], ['scripts']);
});
gulp.task('default', ['styles', 'scripts', 'themes']);