-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (66 loc) · 1.86 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
const { src, dest, watch, series, parallel } = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const del = require('del');
const cleanCss = require('gulp-clean-css');
const mocha = require("gulp-mocha");
const fs = require('fs');
const Configs = {
HERE: './',
DIST: 'dist/',
ASSETS: 'assets/',
CSS: 'assets/css/',
TEMPLATES: 'templates/',
};
/*const TemplateEngines = {
STATIC: 'static',
TWIG_JS: 'twigjs',
TWIG_PHP: 'twigphp',
TEMPLATE_GO: 'templatego',
}*/
function clean() {
return del([
Configs.HERE + Configs.DIST + '**',
'!' + Configs.HERE + Configs.DIST + '.gitkeep'
]);
}
function cssMinify() {
return src(Configs.HERE + Configs.CSS + '*.css')
.pipe(concat("style.css"))
.pipe(cleanCss())
.pipe(rename({ extname: '.min.css' }))
.pipe(dest(Configs.HERE + Configs.DIST + Configs.CSS));
}
function templatesMove() {
return src(Configs.HERE + Configs.TEMPLATES + '**')
.pipe(dest(Configs.HERE + Configs.DIST + Configs.TEMPLATES));
}
function assetsMove() {
return src([Configs.HERE + Configs.ASSETS + '**', '!' + Configs.HERE + Configs.CSS + '**'])
.pipe(dest(Configs.HERE + Configs.DIST + Configs.ASSETS));
}
function watchTemplates() {
return watch([Configs.HERE + Configs.TEMPLATES + '**/**'], series(
clean,
parallel(cssMinify, templatesMove, assetsMove),
));
}
function build() {
return series(
clean,
parallel(cssMinify, templatesMove, assetsMove),
)
}
function runTests(cb) {
return src(['**/*.test.js'])
.pipe(mocha())
.on('error', function() {
cb(new Error('Test failed'));
})
.on('end', function() {
cb();
});
}
exports.buildMe = build;
exports.watchMe = watchTemplates;
exports.testMe = runTests;