This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulp.js
86 lines (62 loc) · 2.1 KB
/
gulp.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
"use strict";
var gulp = require('gulp');
gulp.task('coffee-lint', function(){
var coffeelint = require('gulp-coffeelint');
return gulp.src(['./src/coffee/**/*.coffee'])
.pipe(coffeelint())
.pipe(coffeelint.reporter('coffeelint-stylish'));
});
gulp.task('coffee', function(){
var coffee = require('gulp-coffee');
return gulp.src(['./src/coffee/**/*.coffee'])
.pipe(coffee({bare: true}))
.pipe(gulp.dest('./src/js'));
});
gulp.task('less', function(){
var less = require('gulp-less');
return gulp.src('./src/less/*.less')
.pipe(less())
.pipe(gulp.dest('./src/js/*.css'));
});
gulp.task('jshint',['coffee'], function(){
var jshint = require('gulp-jshint');
return gulp.src(['./src/js/*.js','./src/js/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('wiredep', function () {
var wiredep = require('wiredep').stream;
return gulp.src('src/view/**/*.html')
.pipe(wiredep({
directory: 'bower_components'
}))
.pipe(gulp.dest('src'));
});
gulp.task('connect', function () {
var connect = require('connect');
var serveStatic = require('serve-static');
var serveIndex = require('serve-index');
var app = connect()
.use(require('connect-livereload')({ port: 35729 }))
.use(serveStatic('app'))
.use(serveIndex('app'));
require('http').createServer(app)
.listen(9000)
.on('listening', function() {
console.log('Started connect web server on http://localhost:9000.');
});
});
gulp.task('server', ['less','coffee','connect'], function () {
var livereload = require('gulp-livereload');
livereload.listen();
require('opn')('http://localhost:9000');
gulp.watch([
'src/view/**/*.html',
'src/less/**/*.less',
'src/js/**/*.js',
'src/coffee/**/*.coffee'
],['less','coffee']).on('change', livereload.changed);
gulp.watch('bower.json', ['wiredep']);
});
gulp.task('build',['coffee-lint','jshint','less']);
gulp.task('default',['server']);