-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
59 lines (49 loc) · 1.58 KB
/
gulpfile.coffee
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
gulp = require 'gulp'
gls = require 'gulp-live-server'
gulpsync = require('gulp-sync')(gulp)
clean = require 'gulp-clean'
gutil = require 'gulp-util'
size = require 'gulp-size'
webpack = require 'webpack'
webpackConfig = require './webpack.config.js'
webpackProductionConfig = require './webpack.production.config.js'
gulp.task('clean', ->
gulp.src('public', {
read: false
})
.pipe(clean())
)
gulp.task('copy-assets', ->
gulp.src('assets/**')
.pipe(gulp.dest('public'))
.pipe(size())
)
gulp.task 'webpack:build', (callback) ->
webpack webpackProductionConfig, (err, stats) ->
throw new gutil.PluginError('webpack:build', err) if err
gutil.log '[webpack:build]', stats.toString colors: true
callback()
return
return
gulp.task 'webpack:build-dev', (callback) ->
webpack webpackConfig, (err, stats) ->
throw new gutil.PluginError('webpack:build-dev', err) if err
gutil.log '[webpack:build-dev]', stats.toString
colors: true
chunks: false
callback()
return
return
gulp.task 'default', ['watch']
gulp.task 'build', gulpsync.sync ['clean', ['webpack:build', 'copy-assets']]
gulp.task 'builddev', ['webpack:build-dev', 'copy-assets']
gulp.task 'serve', gulpsync.sync(['clean', ['webpack:build', 'copy-assets']]), ->
server = gls.static('./public/')
server.start()
gulp.task 'watch', ['webpack:build-dev', 'copy-assets'], ->
server = gls.static('./public/')
server.start()
gulp.watch 'public/**', (file) ->
server.notify.apply server, [file]
gulp.watch('app/**', ['webpack:build-dev'])
gulp.watch('assets/**', ['copy-assets'])