forked from tristanfrn/360_LDN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·163 lines (126 loc) · 3.6 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Include gulp
var gulp = require('gulp');
// Include our plugins
// Jade tasks
var jade = require('gulp-jade');
// CSS tasks
var less = require('gulp-less');
var minifyCss = require('gulp-minify-css');
var prefixCss = require('gulp-autoprefixer');
// JS tasks
var uglifyJS = require('gulp-uglify');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
// Various tasks
var rename = require('gulp-rename');
var liveReload = require('gulp-livereload');
var concat = require('gulp-concat');
var filesize = require('gulp-filesize');
var htmlhint = require("gulp-htmlhint");
// var imageop = require('gulp-image-optimization');
var imagemin = require('gulp-imagemin');
/* ------------- */
/* DEFAULT TASKS */
/* ------------- */
// COMPILE JADE TEMPLATE
gulp.task('jade', function() {
// Pages to compile
var pages = ['home'];
gulp.src('src/jade/index.jade')
.pipe(jade({
pretty : true,
locals : { page : "home" }
}))
.pipe(rename("index.html"))
.pipe(gulp.dest('dist/'))
});
// COMPILE LESS FILES
gulp.task('less', function() {
return gulp.src('src/less/main.less')
.pipe(less())
.pipe(prefixCss())
.pipe(minifyCss())
.pipe(filesize())
.pipe(rename('style.css'))
.pipe(gulp.dest('dist/css'));
});
// COMPILE SCRIPTS
gulp.task('scripts', function() {
// Add files here
var appFiles = [
'src/js/*.js'
];
return gulp.src(appFiles)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(concat('app.min.js'))
.pipe(uglifyJS())
.pipe(filesize())
.pipe(gulp.dest('dist/js'));
});
/* ----------- */
/* OTHER TASKS */
/* ----------- */
// COMPILE VENDOR FILES
gulp.task('vendor', function() {
// Add files here
var vendorFiles = [
'src/js/vendor/jquery.min.js',
'src/js/vendor/modernizr.min.js',
'src/js/vendor/video.js'
];
return gulp.src(vendorFiles)
.pipe(concat('vendor.min.js'))
.pipe(filesize())
.pipe(gulp.dest('dist/js'));
});
// COMPILE VENDOR FILES
gulp.task('hammer', function() {
// Add files here
var vendorFiles = [
'src/js/hammer/hammer.js'
];
return gulp.src(vendorFiles)
.pipe(concat('hammer.min.js'))
.pipe(filesize())
.pipe(gulp.dest('dist/js'));
});
// OPTIMIZE IMAGES
gulp.task('images', function() {
gulp.src(['src/img/**/*.png','src/img/**/*.jpg','src/img/**/*.gif','src/img/**/*.jpeg'])
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));
});
// INSTALL RESET.CSS
gulp.task('install', function() {
// Move the css reset
return gulp.src('src/less/reset.css')
.pipe(minifyCss())
.pipe(gulp.dest('dist/css'));
});
/* ----------------- */
/* WATCH FOR CHANGES */
/* ----------------- */
// Watch Files For Changes
gulp.task('watch', function() {
console.log("watching ...");
// Livereload server
var liveServer = liveReload();
gulp.watch('src/jade/**/*.*', ['jade'])
.on('change', function(event){
liveServer.changed(event.path);
console.log('Reloading for Jade');
});
gulp.watch('src/js/**/*.*', ['scripts'])
.on('change', function(event){
liveServer.changed(event.path);
console.log('Reloading for JS');
});
gulp.watch('src/less/**/*.*', ['less'])
.on('change', function(event){
liveServer.changed(event.path);
console.log('Reloading for CSS');
});
});
// Default Task
gulp.task('default', ['jade', 'less', 'vendor', 'scripts', 'watch']);