-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
89 lines (75 loc) · 1.73 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
'use strict';
const { src, dest, parallel, series } = require('gulp');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const jasmine = require('gulp-jasmine');
const del = require('del');
const webserver = require('gulp-webserver');
let destForBuild = 'dist/assets';
let destForDemo = 'demo/assets';
let output
// Build environment
function initBuild(cb) {
output = destForBuild;
cb();
}
// Demo environment
function initBuildDemo(cb) {
output = destForDemo;
cb();
}
// Scripts
function js() {
return src('src/scripts/*.js')
.pipe(dest(output + '/js'));
};
// Libs
function copyLibs() {
return src('src/libs/*.js')
.pipe(dest(output + '/js'));
};
function copyLibsAndMinify() {
return src('src/libs/*.js')
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe(uglify())
.pipe(dest(output + '/js'));
};
// Styles
function css() {
return src('src/styles/*.css')
.pipe(dest(output + '/css'));
};
// HTML
function html() {
return src('src/html/*.html')
.pipe(dest('demo'));
};
// Clean
function clean() {
return del(['dist/*', 'demo/*']);
};
// Tests
function test() {
return src('tests/utils.js')
.pipe(jasmine());
};
// Demo
function runDemo() {
return src('demo')
.pipe(webserver({
open: false,
livereload: false,
directoryListing: false,
fallback: 'index.html'
}));
};
let buildPipeline = series(initBuild, parallel(js, copyLibsAndMinify), test)
let buildDemoPipeline = series(initBuildDemo, parallel(js, copyLibs, css, html), test)
exports.clean = clean;
exports.build = buildPipeline;
exports.buildDemo = buildDemoPipeline;
exports.runDemo = runDemo;
exports.test = test;
exports.default = series(clean, buildPipeline);