-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
71 lines (54 loc) · 1.74 KB
/
gulpfile.babel.js
File metadata and controls
71 lines (54 loc) · 1.74 KB
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
'use strict';
import gulp from 'gulp'
import stylus from 'gulp-stylus' // stylus preprocessor
import livereload from 'gulp-livereload' // live reload
import cleancss from 'gulp-clean-css' // minifi css
import webpackstream from 'webpack-stream' // gulp webpack
import gutil from 'gulp-util' // gulp util
import nodemon from 'gulp-nodemon' // restart nodemon from gulp
import babelconfig from './webpack.config' // webpack config
import uglify from 'gulp-uglify'
var prod = gutil.env.type == 'production';
// js
gulp.task('js', () => {
gulp.src(['src/js/index.js'], { base: 'src' })
.pipe(webpackstream(babelconfig))
.pipe(prod ? uglify() : gutil.noop())
.pipe(gulp.dest('./public/js'))
.pipe(livereload())
})
gulp.task('nodemon', () => {
nodemon({
script: './server/index.js'
, ext: 'html js'
, ignore: [ ".git", "src/**/*", "public/**/*", "node_modules/**/node_modules"]
})
.on('restart', () => {
gutil.log(gutil.colors.cyan('--> nodemon restarted'))
// Give it 1 sec to make sure server's done restarting
setTimeout(() => {
livereload.reload()
console.log('reloaded')
}, 1000)
})
})
// Process stylus
gulp.task('stylus', () => {
gulp.src(['./src/css/**/*.styl'], { base: 'src' })
.pipe(stylus())
.pipe(prod ? cleancss() : gutil.noop())
.pipe(gulp.dest('./public'))
.pipe(livereload())
});
// For the Watch!!
gulp.task('watch', () => {
if (!prod) {
livereload({ start: true })
livereload.listen()
}
gulp.watch('./src/**/*.js', ['js'])
gulp.watch('./src/css/**/*.styl', ['stylus'])
});
gulp.task('dev', ['watch', 'nodemon'])
// call with gulp build --type production
gulp.task('build', ['js', 'stylus'])