forked from jokamjohn/cloud-vision-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
56 lines (48 loc) · 1.48 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
'use strict'
const gulp = require('gulp')
const gutil = require('gulp-util')
const plumber = require('gulp-plumber')
const eslint = require('gulp-eslint')
const seq = require('run-sequence')
const webpack = require('webpack')
const wpStream = require('webpack-stream')
const webpackConfig = require('./webpack.config.js')
const wDevServer = require('webpack-dev-server')
const CLIENT_JS_ENTRY_POINT = 'src/javascripts/main.js'
gulp.task('default', () => {
seq('lint', 'webpack-dev-server')
})
gulp.task('build', () => {
seq('lint', '_build')
})
gulp.task('lint', () => {
return gulp.src([
'*.js',
'src/javascripts/**/*.js',
'!build'
])
.pipe(eslint({configFile: '.eslintrc.json'}))
.pipe(eslint.format())
// .pipe(eslint.failOnError())
})
gulp.task('_build', () => {
gulp.src('public/**/*').pipe(gulp.dest('build/prod'))
return gulp.src(CLIENT_JS_ENTRY_POINT)
.pipe(plumber())
.pipe(wpStream(webpackConfig))
.pipe(gulp.dest('build/prod/'))
})
gulp.task('webpack-dev-server', () => {
gulp.src('public/**/*').pipe(gulp.dest('build/dev'))
// Start a webpack-dev-server
new wDevServer(webpack(webpackConfig), {
contentBase: 'build/dev/',
stats: {
colors: true
}
}).listen(3000, 'localhost', (err) => {
if(err) throw new gutil.PluginError('webpack-dev-server', err)
// Server listening
gutil.log('[webpack-dev-server]', 'http://localhost:3000/webpack-dev-server/index.html')
})
})