forked from framework7io/ToDo7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
115 lines (104 loc) · 3.53 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
(function(){
'use strict';
var gulp = require('gulp'),
connect = require('gulp-connect'),
open = require('gulp-open'),
less = require('gulp-less'),
jade = require('gulp-jade'),
path = require('path'),
fs = require('fs'),
paths = {
root: './',
css: 'css/',
js: 'js/',
source: {
less: 'src/less/',
jade: 'src/jade/'
}
},
app = {
filename: 'todo7',
pkg: require('./bower.json'),
banner: [
'/**',
' * <%= pkg.name %> <%= pkg.version %>',
' * <%= pkg.description %>',
' * ',
' * <%= pkg.homepage %>',
' * ',
' * Copyright <%= date.year %>, <%= pkg.author %>',
' * The iDangero.us',
' * http://www.idangero.us/',
' * ',
' * Licensed under <%= pkg.license.join(" & ") %>',
' * ',
' * Released on: <%= date.month %> <%= date.day %>, <%= date.year %>',
' */',
''].join('\n'),
date: {
year: new Date().getFullYear(),
month: ('January February March April May June July August September October November December').split(' ')[new Date().getMonth()],
day: new Date().getDate()
},
};
/* ==================================================================
Build App
================================================================== */
gulp.task('styles', function (cb) {
gulp.src([paths.source.less + app.filename + '.less'])
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(gulp.dest(paths.css))
.pipe(connect.reload())
.on('end', function () {
cb();
});
});
gulp.task('jade', function (cb) {
gulp.src([paths.source.jade + '*.jade'])
.pipe(jade({
pretty: true,
}))
.pipe(gulp.dest(paths.root))
.pipe(connect.reload())
.on('end', function () {
cb();
});
});
gulp.task('build', ['styles', 'jade'], function (cb) {
cb();
});
/* =================================
Watch
================================= */
gulp.task('watch', function () {
gulp.watch(paths.source.less + '*.less', [ 'styles' ]);
gulp.watch(paths.source.jade + '*.jade', [ 'jade' ]);
gulp.watch(paths.css + '*.css', function () {
gulp.src(paths.css)
.pipe(connect.reload());
});
gulp.watch(paths.js + '*.js', function () {
gulp.src(paths.js)
.pipe(connect.reload());
});
gulp.watch(paths.root + '*.html', function () {
gulp.src(paths.root)
.pipe(connect.reload());
});
});
gulp.task('connect', function () {
return connect.server({
root: [ paths.root ],
livereload: true,
port:'3000'
});
});
gulp.task('open', function () {
return gulp.src(paths.root + 'index.html').pipe(open({ uri: 'http://localhost:3000/index.html'}));
});
gulp.task('server', [ 'watch', 'connect', 'open' ]);
gulp.task('default', [ 'server' ]);
gulp.task('test', [ 'build' ]);
})();