-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (45 loc) · 1.44 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
'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var paths = {
appScripts: 'src/app/**/*.js'
};
gulp.task('scripts', function () {
return gulp.src([paths.appScripts])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter(require('jshint-stylish')))
.pipe(plugins.size());
});
gulp.task('watch', ['serve'], function () {
var server = plugins.livereload();
gulp.watch([
'src/**/*.html',
'src/app/**/*.js',
'src/styles/*.css'
]).on('change', function (file) {
console.log('File changed: ' + file.path);
server.changed(file.path);
});
gulp.watch(paths.appScripts, ['scripts']);
});
gulp.task('injectjs', function(){
var target = gulp.src('./src/index.html');
var sources = gulp.src([paths.appScripts]);
return target.pipe(plugins.inject(sources, {relative: true}))
.pipe(gulp.dest('./src'));
});
gulp.task('serve', ['connect'], function () {
require('opn')('http://localhost:9000');
});
gulp.task('connect', function () {
var connect = require('connect');
var app = connect()
.use(require('connect-livereload')({ port: 35729 }))
.use(connect.static('src'))
.use(connect.directory('src'));
require('http').createServer(app)
.listen(9000)
.on('listening', function () {
console.log('Started connect web server on http://localhost:9000');
});
});