-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.coffee
More file actions
61 lines (52 loc) · 1.93 KB
/
gulpfile.coffee
File metadata and controls
61 lines (52 loc) · 1.93 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
gulp = require 'gulp'
path = require 'path'
touch = require 'touch'
LessPluginCleanCSS = require 'less-plugin-clean-css'
webpack = require 'webpack'
WebpackDevServer = require 'webpack-dev-server'
webpackConfig = require './webpack.config'
webpackProductionConfig = require './webpack.production.config'
$ = require('gulp-load-plugins')()
gulp.task 'css', ->
gulp.src 'src/styles/**/*.less'
.pipe $.less plugins: [ new LessPluginCleanCSS advanced: true ]
.on 'error', (err) -> $.util.log err
.pipe gulp.dest './public'
.pipe $.size()
gulp.task 'copy-assets', ->
gulp.src ['assets/**', '!assets/**/*~']
.pipe gulp.dest './public'
.pipe $.size()
gulp.task 'webpack:build', ['css'], (cb) ->
webpack webpackProductionConfig, (err, stats) ->
throw new $.util.PluginError('webpack:build', err) if err
$.util.log '[webpack:build]', stats.toString colors: true
cb()
return
devCompiler = webpack webpackConfig
gulp.task 'webpack:build-dev', ['css'], (cb) ->
devCompiler.run (err, stats) ->
throw new $.util.PluginError('webpack:build-dev', err) if err?
$.util.log '[webpack:build-dev]', stats.toString colors: true
cb()
return
devServer = {}
gulp.task 'webpack-dev-server', ['css'], (cb) ->
touch.sync './public/main.css', time: new Date 0
devServer = new WebpackDevServer devCompiler,
contentBase: './public/'
hot: true
watchDelay: 100
noInto: true
quiet: true
.listen 8080, '0.0.0.0', (err, result) ->
throw new $.util.PluginError('webpack-dev-server', err) if err?
$.util.log '[webpack-dev-server]', 'http://localhost:8080'
cb()
return
gulp.task 'default', ->
gulp.start 'build'
gulp.task 'build', ['webpack:build', 'copy-assets']
gulp.task 'watch', ['css', 'copy-assets', 'webpack-dev-server'], ->
gulp.watch ['src/styles/**'], ['css']
gulp.watch ['assets/**'], ['copy-assets']