forked from learnsyncly/learnsyncly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
executable file
·68 lines (58 loc) · 1.89 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
var gulp = require('gulp');
var gulpLoadPlugins = require('gulp-load-plugins');
var plugin = gulpLoadPlugins();
var browserify = require('browserify');
var vss = require('vinyl-source-stream');
var stylish = require('jshint-stylish');
//TODO preventy copying files which will be concat/minified during build
var copyFiles = [
'./src/**/*'
// '!./src/public/css/',
// '!./src/public/lib/',
];
//Build for Heroku
gulp.task('heroku:production', ['build']);
//copy dev to build
gulp.task('copyToBuild', function(){
return gulp.src(copyFiles).pipe(gulp.dest('./build'));
});
//lint
gulp.task('lint', function() {
return gulp.src(['./src/public/app/**/*.js','!src/public/lib/allLibs.js'])
.pipe(plugin.jshint())
.pipe(plugin.jshint.reporter(stylish));
});
//browserify using vinyl source streams (gulp-browserify no longer maintained)
//allLibs.js must be deleted before running or there will be an error
gulp.task('browserify', function() {
//file to browserify
return browserify('./src/public/app/app.js')
.bundle()
.on('error', function(err){console.log(err.message);})
//output name
.pipe(vss('allLibs.js'))
.on('error', function(err){console.log(err.message);})
//output location
.pipe(gulp.dest('./src/public/lib/'))
.on('error', function(err){console.log(err.message);});
});
//start dev version using nodemon
gulp.task('nodemon', function(){
return plugin.nodemon({script: 'src/server.js', watch: ['src/server/**/*','src/server.js']});
});
//start build version
gulp.task('start', function(){
return plugin.shell.task([
'echo Starting the server!',
'node build/server.js'
]);
}
);
//watch
gulp.task('watch', function(){
return gulp.watch('./src/public/app/**/*', ['build']);
});
//build
gulp.task('build', ['lint','browserify','copyToBuild']);
//DEV TO LAUNCH NODEMON AND KEEP AN EYE ON FILES AUTOMATICALLY
gulp.task('dev', ['watch','nodemon']);