This repository has been archived by the owner on Feb 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
80 lines (70 loc) · 2.1 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
var gulp = require('gulp')
, nodemon = require('gulp-nodemon')
, concat = require('gulp-concat')
, bower = require('main-bower-files')
, fixtures = require('sequelize-fixtures')
, mocha = require('gulp-mocha')
, uglify = require('gulp-uglify')
, browserSync = require('browser-sync').create();
gulp.task('browser-sync', ['nodemon'], function(){
browserSync.init(__dirname, {
proxy: "localhost:3000"
, port: 9000
, open: false
});
});
gulp.task('nodemon', function(){
return nodemon({
script: 'app.js'
, ignore: ['public/**']
, env : { 'NODE_ENV': 'development'}
})
.on('restart', function(){
setTimeout(function(){
browserSync.reload({stream: true});
}, 500);
});
});
gulp.task('bower', function(){
return gulp.src(bower(), {
base: 'public/components'
})
.pipe(concat('components.min.js'))
.pipe(gulp.dest('public/dest'));
});
gulp.task('script', function(){
return gulp.src('public/modules/**/*.js')
.pipe(concat('app-build.js'))
.pipe(uglify())
.pipe(gulp.dest('public/dest'));
});
gulp.task('fixtures', function(){
require('dotenv').load();
fixtures.loadFile("config/data/**.yml", require('./app/models'));
});
gulp.task('test', function(){
process.env.NODE_ENV = 'test';
return gulp.src('test/*.test.js', { read: false })
.pipe(mocha({ timeout: 25000 }))
.once('error', function(){
process.exit(1);
}).once('end', function(){
process.exit();
});
});
gulp.task('watch', function(){
//Watch jade files
gulp.watch(['app/views/**/*.jade', 'public/modules/**/*.jade'], function(){
browserSync.reload('index.html', { stream: true });
});
//Watch sass files
gulp.watch('public/css/*.sass', function(){
browserSync.reload('bitvagas.css', { stream: true });
});
//Watch js files
gulp.watch('public/modules/**/*.js', ['script'], function(){
browserSync.reload();
});
});
gulp.task('build', ['script']);
gulp.task('default', ['browser-sync','script', 'watch']);