-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (63 loc) · 1.83 KB
/
gulpfile.js
File metadata and controls
72 lines (63 loc) · 1.83 KB
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
//IMPORT THE REQUIRED LIBS
var gulp = require('gulp');
var server = require('gulp-express');
var less = require('gulp-less');
var inject = require('gulp-inject');
var path = require('path');
var runSequence = require('run-sequence');
var wiredep = require('wiredep').stream;
//DEFINE GLOBAL PATHS
var config = {
app: 'app',
dist: 'dist'
};
//Inject the bower.json dependencies in index.html file
gulp.task('wiredep', function () {
gulp.src(path.join(config.app, '/index.html'))
.pipe(wiredep())
.pipe(gulp.dest(config.app));
});
var injectCustom = function() {
var sources = gulp.src([
path.join('!' + config.app, '/bower_components/**/*'),
path.join(config.app, '/**/*.js')
], { read: false });
return inject(sources, { relative: true });
};
/*
* Injects both vendor and customs scripts and styles into the index.html file.
* Leaves the output file in the '.tmp' folder.
*/
gulp.task('inject', ['less'], function () {
return gulp.src(path.join(config.app, '/index.html'))
.pipe(injectCustom())
.pipe(gulp.dest(path.join(config.app)));
});
gulp.task('less', function () {
return gulp.src([
path.join(config.app, 'styles/less/**/*.less'),
path.join('!' + config.app, '/bower_components/**/*')
])
.pipe(less())
.pipe(gulp.dest(path.join(config.app, '/styles/css')));
});
var lessAndReload = function(event) {
runSequence('less', function() {
server.notify(event);
});
};
gulp.task('watch', function () {
gulp.watch(['./app/**/*.html'], server.notify);
gulp.watch(['./app/scripts/**/*.js'], server.notify);
gulp.watch(['./app/styles/**/*.less'], lessAndReload);
gulp.watch(['./server/**/*.js'], server.notify);
});
gulp.task('server', function () {
server.run(['server/app.js']);
});
gulp.task('default', [
'inject',
'server',
'wiredep',
'watch'
]);