-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (78 loc) · 2.2 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
// Include gulp and gulp
var gulp = require('gulp'),
//general
ifelse = require('gulp-if-else'),
connect = require('gulp-connect'),
rename = require('gulp-rename'),
//html
fileinclude = require('gulp-file-include'),
htmlPrettify = require('gulp-html-prettify'),
//css
cssnano = require('gulp-cssnano'),
//async
async = require('async');
//initiate variables
var env,
htmlSources,
cssSources,
outputDir;
var outputDir = 'build/'; //set output directory to production
componentSources = ['components/**/*'];
htmlSources = ['components/html/templates/**/*.html'];
templateSources = ['components/html/modules/**/*.html'];
cssSources = ['components/css/**/*.css'];
//HTML task
gulp.task('html', function(){
async.series([
function(next)
{
gulp.src(htmlSources)
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(htmlPrettify({indent_char:' ',indent_size:4}))
.pipe(gulp.dest(outputDir+'templates/'))
.on('end',next);
},
function(next)
{
gulp.src(componentSources)
.pipe(connect.reload());
}
])
});
gulp.task('css', function(){
async.series([ //development build functions
function(next)
{
gulp.src(cssSources)
.pipe(gulp.dest(outputDir+'css/'))
.pipe(cssnano({zindex: false}))
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest(outputDir+'css/'))
.on('end',next);
},
function(next)
{
gulp.src(componentSources)
.pipe(connect.reload());
}
]);
});
gulp.task('watch', function() {
gulp.watch(htmlSources,['html']);
gulp.watch(templateSources,['html']);
gulp.watch(cssSources,['css']);
});
gulp.task('connect', function() {
connect.server({
root: outputDir,
livereload: true
});
});
// Default Task
/*gulp.task('default', ['fileinclude','html','lint','css','scripts','watch']);*/
gulp.task('default',['html','css','connect','watch']);