2015-11-14 00:57:36 +01:00
|
|
|
var gulp = require('gulp')
|
2015-11-20 14:20:06 +01:00
|
|
|
var webpack = require('webpack-stream')
|
2015-11-14 00:57:36 +01:00
|
|
|
var clean = require('gulp-clean')
|
2015-11-14 01:34:03 +01:00
|
|
|
var connect = require('gulp-connect')
|
2015-11-19 18:06:45 +01:00
|
|
|
var ghPages = require('gulp-gh-pages')
|
2015-11-14 00:57:36 +01:00
|
|
|
|
|
|
|
var config = {
|
|
|
|
files: {
|
2015-11-14 01:34:03 +01:00
|
|
|
mainJs: 'webapp/app.jsx',
|
2015-11-14 00:57:36 +01:00
|
|
|
css: 'webapp/*.css',
|
2015-11-14 01:34:03 +01:00
|
|
|
js: ['webapp/*.js','webapp/*.jsx'],
|
2015-11-14 15:03:38 +01:00
|
|
|
html: 'webapp/*.html',
|
|
|
|
jsLibs: 'lib/*.js'
|
2015-11-14 00:57:36 +01:00
|
|
|
},
|
|
|
|
dest: 'webapp/dist/'
|
|
|
|
}
|
|
|
|
|
2015-11-20 14:20:06 +01:00
|
|
|
gulp.task('watch',function(){
|
|
|
|
var cfg = require('./webpack.config.js')
|
|
|
|
cfg.watch = true
|
|
|
|
return gulp.src(config.files.mainJs)
|
|
|
|
.pipe(webpack(cfg))
|
|
|
|
.pipe(gulp.dest(config.dest))
|
|
|
|
.pipe(connect.reload())
|
2015-11-14 00:57:36 +01:00
|
|
|
})
|
|
|
|
|
2015-11-20 14:20:06 +01:00
|
|
|
gulp.task('build',function(){
|
|
|
|
return gulp.src(config.files.mainJs)
|
|
|
|
.pipe(webpack(require('./webpack.config.js')))
|
|
|
|
.pipe(gulp.dest(config.dest))
|
2015-11-14 00:57:36 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('clean',function(){
|
2015-11-15 21:34:41 +01:00
|
|
|
return gulp.src(config.dest, { read: false }).pipe(clean())
|
2015-11-14 00:57:36 +01:00
|
|
|
})
|
|
|
|
|
2015-11-14 10:46:42 +01:00
|
|
|
gulp.task('server',function(){
|
2015-11-14 01:34:03 +01:00
|
|
|
connect.server({
|
|
|
|
root: config.dest,
|
|
|
|
port: 9090,
|
|
|
|
livereload: true
|
2015-11-14 10:46:42 +01:00
|
|
|
})
|
2015-11-14 01:34:03 +01:00
|
|
|
})
|
|
|
|
|
2015-11-20 14:20:06 +01:00
|
|
|
gulp.task('gh-pages',[ 'build' ],function(){
|
2015-11-19 18:06:45 +01:00
|
|
|
gulp.src([config.dest+'*.js',config.dest+'*.css',config.dest+'*.html'])
|
|
|
|
.pipe(ghPages())
|
|
|
|
})
|
|
|
|
|
2015-11-20 14:20:06 +01:00
|
|
|
gulp.task('serve', [ 'watch', 'server' ])
|
2015-11-14 10:46:42 +01:00
|
|
|
|
2015-11-20 14:20:06 +01:00
|
|
|
gulp.task('default', [ 'build' ])
|