forked from bmlt-enabled/crouton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
115 lines (103 loc) · 2.74 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const { watch, task, src, dest, series } = require('gulp');
const concat = require('gulp-concat');
const minify = require('gulp-minify');
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
const handlebars = require('gulp-handlebars');
const wrap = require('gulp-wrap');
const declare = require('gulp-declare');
const notify = require('gulp-notify');
let jsFilesNoJQuery = [
'bootstrap.min.js',
'select2.full.min.js',
'tablesaw.jquery.3.0.9.js',
'handlebars-v4.5.3.js',
'moment.js',
'moment-timezone.js',
'crouton-localization.js',
'templates.js',
'crouton-core.js',
'punycode.1.4.1.js',
'markerclusterer-2.0.3.js',
'oms-1.0.3.min.js',
];
let jsFilesWithJquery = [
'jquery-3.4.1.min.js',
].concat(jsFilesNoJQuery);
let cssFiles = [
'select2.min.css',
'bootstrap.min.css',
'bmlt_tabs.css',
];
let distDir = 'croutonjs/dist';
task('js-files-nojquery', () => {
let jsFilesWithFullPath = [];
for (let jsFile of jsFilesNoJQuery) {
jsFilesWithFullPath.push('croutonjs/src/js/' + jsFile);
}
return src(jsFilesWithFullPath)
.pipe(concat('crouton.nojquery.js'))
.pipe(dest(distDir))
.pipe(minify({
ext: {
min:'.min.js'
},
}))
.pipe(dest(distDir))
.pipe(notify({message:"js-files-nojquery complete", wait: true}));
});
task('js-files', () => {
let jsFilesWithFullPath = [];
for (let jsFile of jsFilesWithJquery) {
jsFilesWithFullPath.push('croutonjs/src/js/' + jsFile);
}
return src(jsFilesWithFullPath)
.pipe(concat('crouton.js'))
.pipe(dest(distDir))
.pipe(minify({
ext: {
min:'.min.js'
},
}))
.pipe(dest(distDir))
.pipe(notify({message: "js-files complete", wait: true}));
});
task('templates', function () {
return src('croutonjs/src/templates/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'hbs_Crouton.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(dest('croutonjs/src/js'))
.pipe(notify({message: "templates complete", wait: true}));
});
task('css-files', () => {
let cssFilesWithFullPath = [];
for (let cssFile of cssFiles) {
cssFilesWithFullPath.push('croutonjs/src/css/' + cssFile);
}
return src(cssFilesWithFullPath)
.pipe(concat('crouton.css'))
.pipe(dest(distDir))
.pipe(cleanCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(dest(distDir))
.pipe(notify({message: "css-files complete", wait: true}));
});
task('default', series('templates', 'js-files', 'js-files-nojquery', 'css-files'));
task('watch', () => {
watch([
'croutonjs/src/templates/*.hbs'
], series('templates'));
watch([
'croutonjs/src/js/*.js'
], series('js-files', 'js-files-nojquery'));
watch([
'croutonjs/src/css/*.css'
], series('css-files'));
});