-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
59 lines (50 loc) · 1.81 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
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var spawn = require('child_process').spawn;
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
gulp.task('e2etests', function () {
var protractor = spawn('protractor',['protractor.conf.js'],{stdio: 'inherit'});
});
gulp.task('alltests', ['servertests','e2etests']);
gulp.task('servertests', function() {
process.env.NODE_ENV = 'testing';
return gulp.src('test/*.js', {read: false})
.pipe(mocha());
});
//concatenates front-end js files into a single file so the browser needs only one require
gulp.task('scripts', function(){
if (process.env.NODE_ENV === 'production') {
return gulp.src(['public/js/**/*.js', '!public/js/vendor/*'])
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('public/build/'));
} else {
return gulp.src(['public/js/**/*.js', '!public/js/vendor/*'])
.pipe(sourcemaps.init())
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('public/build/'));
}
});
gulp.task('styles', function(){
return gulp.src(['public/css/materialize-src/sass/*.scss', 'public/css/sass/*.scss'])
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(concat('styles.css'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('public/build'));
});
gulp.task('build', ['styles','scripts']);
// gulp.task('watch_scripts', function(){
// });
gulp.task('watch', function() {
// gulp.watch(['lib/**/*.js','test/**/*.js'], ['servertests']);
gulp.watch(['public/js/**/*.js'], ['scripts']);
gulp.watch(['public/css/materialize-src/sass/components/*.scss', 'public/css/sass/*.scss'], ['styles']);
});
gulp.task('seed', function() {
});
gulp.task('default', ['watch']);