-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (55 loc) · 2 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
const gulp = require('gulp');
const { exec } = require('child_process');
const plugins = require('gulp-load-plugins')();
// don't think the plugin loader works with hyphenated plugin names... :(
const FileCache = require('gulp-file-cache');
let cache = new FileCache();
// running 'gulp' with no options defaults to running application
gulp.task('default',
[process.env.NODE_ENV === 'production' ? 'production' : 'development']
);
gulp.task('lint', () => {
return gulp.src(['**/*.js', '!node_modules/**/*.js', '!dist/**/*.js', '!src/client/lib/**/*.js'])
.pipe(plugins.jshint({
esversion: 6
}))
.pipe(plugins.jshint.reporter('jshint-stylish'));
// Uncomment this and remove semicolon above to have JSHint fail when warnings are unresolved
// .pipe(plugins.jshint.reporter('fail'));
});
gulp.task('build', ['build-client', 'build-server', 'test', 'todo']);
gulp.task('build-server', () => {
return gulp.src(['src/server/**/*.*'])
.pipe(cache.filter())
.pipe(gulp.dest('dist/server'));
});
gulp.task('build-client', ['move-client-assets'], () => {
return gulp.src(['src/client/**/*.js', '!src/client/lib/**/*.*'])
.pipe(cache.filter())
.pipe(plugins.babel({
presets: ['env']
}))
.pipe(cache.cache())
.pipe(gulp.dest('./dist/client'));
});
gulp.task('move-client-assets', () => {
return gulp.src(['src/client/**/*.*', '!src/client/*.js'])
.pipe(gulp.dest('./dist/client'));
});
// TODO: Add some kind of testing framework
gulp.task('test', []);
gulp.task('development', ['lint'], () => {
plugins.nodemon({
script: './src/server/server.js',
watch: 'src',
ext: 'html js css'
});
});
gulp.task('production', ['build'], () => {
exec('node ./dist/server/server.js');
});
gulp.task('todo', () => {
gulp.src(['**/*.js', '!node_modules/**/*.js', '!dist/**/*.js', '!src/client/lib/**/*.js'])
.pipe(plugins.todo())
.pipe(gulp.dest('./'));
});