-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
81 lines (63 loc) · 1.58 KB
/
gulpfile.babel.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
81
// third party imports
var gulp = require('gulp')
var del = require('del')
var karma = require('karma')
var webpack = require('webpack-stream')
var named = require('vinyl-named')
// local imports
var projectPaths = require('./config/projectPaths')
var buildDir = projectPaths.buildDir
var entry = projectPaths.entry
var webpackConfigPath = projectPaths.webpackConfig
var karmaConfigPath = projectPaths.karmaConfig
/**
* Default to watching scripts and styles. Rebuild on change.
*/
gulp.task('default', ['watch'])
/**
* Watch js entry point. Rebuild on change.
*/
gulp.task('watch', function () {
const config = require(webpackConfigPath)
config.watch = true
return gulp.src(entry)
.pipe(named())
.pipe(webpack(config))
.pipe(gulp.dest(buildDir))
})
/**
* Run test suite once.
*/
gulp.task('test', function (cb) {
const server = new karma.Server({
configFile: karmaConfigPath,
singleRun: true
}, function () { cb() })
server.start()
})
/**
* Watch tests for changes, run tests on change.
*/
gulp.task('tdd', function () {
const server = new karma.Server({
configFile: karmaConfigPath,
})
server.start()
})
/**
* Build js entry point for production.
*/
gulp.task('build-production', ['clean'], function () {
process.env.NODE_ENV = 'production'
// build client
return gulp.src(entry)
.pipe(named())
.pipe(webpack(require(webpackConfigPath)))
.pipe(gulp.dest(buildDir))
})
/**
* Remove ALL previously built files.
*/
gulp.task('clean', function () {
del.sync(buildDir)
})