forked from heracek/este-todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (45 loc) · 1.73 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
var bg = require('gulp-bg')
var gulp = require('gulp')
var harmonize = require('harmonize')
var jest = require('jest-cli')
var makeWebpackConfig = require('./webpack/makeconfig')
var runSequence = require('run-sequence')
var webpackBuild = require('./webpack/build')
var webpackDevServer = require('./webpack/devserver')
var yargs = require('yargs')
// Enables node's --harmony flag programmatically for jest.
harmonize()
var args = yargs
.alias('p', 'production')
.argv
gulp.task('env', function() {
process.env.NODE_ENV = args.production ? 'production' : 'development'
})
gulp.task('build-webpack-production', webpackBuild(makeWebpackConfig(false)))
gulp.task('build-webpack-dev', webpackDevServer(makeWebpackConfig(true)))
gulp.task('build-webpack', [args.production ? 'build-webpack-production' : 'build-webpack-dev'])
gulp.task('build', ['build-webpack'])
gulp.task('jest', function(done) {
var rootDir = './src'
function onComplete(success) {
done(success ? null : 'jest failed')
process.on('exit', function() {
process.exit(success ? 0 : 1)
})
}
jest.runCLI({config: {
'rootDir': rootDir,
'scriptPreprocessor': '../node_modules/babel-jest',
'testFileExtensions': ['es6', 'js'],
'moduleFileExtensions': ['js', 'json', 'es6']
}}, rootDir, onComplete)
})
// TODO: Add es6lint.
gulp.task('test', function(done) {
// Run test tasks serially, because it doesn't make sense to build when tests
// are not passing, and it doesn't make sense to run tests, if lint has failed.
// Gulp deps aren't helpful, because we want to run tasks without deps as well.
runSequence('jest', 'build-webpack-production', done)
});
gulp.task('server', ['env', 'build'], bg('node', 'src/server'))
gulp.task('default', ['server'])