-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (66 loc) · 1.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
var gulp = require('gulp'),
prefixer = require('gulp-autoprefixer'),
include = require('gulp-include'),
coffee = require('gulp-coffee'),
header = require('gulp-header'),
stylus = require('gulp-stylus'),
reload = require('gulp-livereload'),
src = {
coffee: './src/coffee/*.coffee',
stylus: './src/stylus/*.styl',
},
dest = {
coffee: './public_html/js',
stylus: './public_html/css',
},
opt = {
coffee: {bare: false},
header: '/*\n * @author Timur Valiyev\n * @link https://webprowww.github.io\n */\n\n',
prefixer: {browsers: ['last 5 versions'], cascade: true}
},
watch = {
coffee: './src/coffee/**/*.coffee',
stylus: './src/stylus/**/*.styl',
php: ['./backend/**/*.php', './config/**/*.php', './fronted/**/*.php', './public_html/**/*.php']
};
function taskError(err, done) {
console.log(err.message);
return done();
}
function taskCoffee(done) {
gulp.src(src.coffee)
.pipe(include().on('error', function(err) {
taskError(err, done);
}))
.pipe(coffee(opt.coffee).on('error', function(err) {
taskError(err, done);
}))
.pipe(header(opt.header))
.pipe(gulp.dest(dest.coffee))
.pipe(reload());
return done();
}
function taskStylus(done) {
gulp.src(src.stylus)
.pipe(stylus().on('error', function(err) {
taskError(err, done);
}))
.pipe(prefixer(opt.prefixer))
.pipe(header(opt.header))
.pipe(gulp.dest(dest.stylus))
.pipe(reload());
return done();
}
function taskReload(done) {
reload.reload('./public_html/index.php');
return done();
}
function defaultTask(done) {
gulp.watch(watch.coffee, taskCoffee);
gulp.watch(watch.stylus, taskStylus);
gulp.watch(watch.php, taskReload);
reload.listen();
return done();
}
gulp.task('default', defaultTask);
/* gulpfile.js */