forked from themarkappleby/Guidedog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
138 lines (129 loc) · 4.84 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//-- Includes -----------------------------------------------------
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
minify = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
order = require('gulp-order'),
wrap = require('gulp-wrap'),
declare = require('gulp-declare'),
jade = require('gulp-jade'),
concat = require('gulp-concat'),
nodemon = require('gulp-nodemon'),
handlebars = require('gulp-handlebars'),
less = require('gulp-less'),
stylus = require('gulp-stylus'),
notify = require('gulp-notify');
//-- Vendor Dependencies -----------------------------------------------------
var vendorJSDependencies = [
'./bower_components/js-beautify/js/lib/beautify-html.js',
'./bower_components/jade/jade.js',
'./bower_components/markdown/lib/markdown.js',
'./bower_components/handlebars/handlebars.runtime.js',
'./bower_components/prism/prism.js',
'./bower_components/prism/components/prism-haskell.js',
'./bower_components/prism/plugins/line-numbers/prism-line-numbers.js',
'./bower_components/js-yaml/dist/js-yaml.js'
];
var vendorCSSDependencies = [
'./bower_components/prism/themes/prism-coy.css',
'./bower_components/prism/plugins/line-numbers/prism-line-numbers.css'
];
//-- Compile JS -----------------------------------------------------
gulp.task('guidedog-js', function(){
vendorJSDependencies.push('./src/template/guidedog.js');
vendorJSDependencies.push('./src/js/guidedog.js');
gulp.src(vendorJSDependencies)
.pipe(concat('guidedog.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
});
gulp.task('example-js', function(){
gulp.src('./example/src/js/**/*.js')
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./example/build/js/'));
});
//-- Compile Styles -----------------------------------------------------
gulp.task('guidedog-css', function(){
// compile guidedog stylus
gulp.src('./src/styl/**/*.styl')
.pipe(stylus())
.on("error", notify.onError(function (error) {
return "Stylus error: " + error.message;
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(minify())
.pipe(gulp.dest('./src/css/'));
// merge compiled guidedog stylus with vendor CSS
vendorCSSDependencies.push('./src/css/guidedog.css')
gulp.src(vendorCSSDependencies)
.pipe(concat('guidedog.css'))
.pipe(minify())
.pipe(gulp.dest('./dist/'));
});
gulp.task('example-css', function(){
gulp.src('./example/src/styl/styl.styl')
.pipe(stylus())
.on("error", notify.onError(function (error) {
return "Stylus error: " + error.message;
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(minify())
.pipe(gulp.dest('./example/build/css/'));
gulp.src('./example/src/less/less.less')
.pipe(less())
.on("error", notify.onError(function (error) {
return "Less error: " + error.message;
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(minify())
.pipe(gulp.dest('./example/build/css/'));
});
//-- Compile Views -----------------------------------------------------
gulp.task('guidedog-views', function(){
gulp.src('./src/template/guidedog.handlebars')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'Guidedog.templates',
noRedeclare: true,
}))
.pipe(gulp.dest('./src/template/'));
});
gulp.task('example-views', function(){
gulp.src('./example/src/jade/index.jade')
.pipe(jade({
pretty: true
}))
.on("error", notify.onError(function (error) {
return "Jade error: " + error.message;
}))
.pipe(gulp.dest('./example/build/'));
});
//-- Start local server -----------------------------------------------------
gulp.task('server', function() {
nodemon({
verbose: false,
script: 'server.js',
watch: ['source', 'server.js'],
ext: 'js json',
env: {
NODE_ENV: 'development'
}
})
})
//-- Watch Files for Changes -----------------------------------------------------
gulp.task('watch', function(){
gulp.watch('./example/src/jade/index.jade', ['example-views']);
gulp.watch('./example/src/js/**/*.js', ['example-js']);
gulp.watch([
'./example/src/styl/**/*.styl',
'./example/src/less/**/*.less'
], ['example-css']);
gulp.watch('./src/template/guidedog.handlebars', ['guidedog-views', 'guidedog-js']);
gulp.watch('./src/js/guidedog.js', ['guidedog-js']);
gulp.watch('./src/styl/**/*.styl', ['guidedog-css']);
})
//-- Default Task -----------------------------------------------------
gulp.task('default', ['example-views', 'example-js', 'example-css', 'guidedog-views', 'guidedog-js', 'guidedog-css', 'watch', 'server']);