-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.coffee
109 lines (85 loc) · 2.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Utils
gulp = require 'gulp'
merge = require 'merge-stream'
del = require 'del'
gutil = require 'gulp-util'
# CSS
sass = require 'gulp-sass'
autoprefix = require 'autoprefixer'
postcss = require 'gulp-postcss'
assets = require 'postcss-assets'
sourcemaps = require 'gulp-sourcemaps'
# HTML
minifyHTML = require 'gulp-minify-html'
# JS
webpack = require 'webpack'
webpackStr = require 'webpack-stream'
uglify = require 'gulp-uglify'
concat = require 'gulp-concat'
# serve & LR
server = require 'gulp-server-livereload'
# config
serverport = 5001
######
webpackConfig =
entry:
index: './src/js/app.jsx'
output:
filename: 'app.js'
module:
loaders: [
test: /\.jsx?$/
exclude: /(node_modules|bower_components)/
loader: 'babel-loader'
query:
presets: ['react', 'es2015']
]
# console.log webpackConfig.modules.loaders
gulp.task 'clean', -> del ['docs']
gulp.task 'styles', ->
sassStream = gulp.src 'src/css/*.sass'
.pipe sourcemaps.init()
.pipe sass().on 'error', sass.logError
.pipe postcss [
autoprefix
browsers: 'last 2 versions'
# assets
# loadPaths: ['src/assets'] # noop for now
]
.pipe sourcemaps.write()
.pipe concat 'sass.css'
cssStream = gulp.src 'src/css/*.css'
.pipe concat 'css.css'
merge(cssStream, sassStream)
.pipe concat 'styles.css'
.pipe gulp.dest 'docs/css'
gulp.task 'scripts', ->
gulp.src '.'
.pipe sourcemaps.init()
# .pipe named()
.pipe webpackStr(webpackConfig, webpack)
.on 'error', (e) ->
# gutil.log gutil.colors.red 'Webpack error:\n' + e.message
@emit 'end'
.pipe sourcemaps.write '.'
.pipe gulp.dest 'docs/js'
gulp.task 'html', ->
gulp.src 'src/*.html'
.pipe gulp.dest 'docs/'
gulp.task 'assets', ->
gulp.src('src/assets/**')
# .pipe imagemin optimizationLevel: 5
.pipe gulp.dest 'docs/assets/'
gulp.task 'serve', ->
gulp.src 'docs'
.pipe server
port: 5001
livereload: true
directoryListing: false
open: false
gulp.task 'watch', ->
gulp.watch 'src/js/**', ['scripts']
gulp.watch 'src/css/**', ['styles']
gulp.watch 'src/*.html', ['html']
gulp.watch 'src/assets/**', ['assets']
gulp.task 'default', ['scripts', 'styles', 'html', 'assets', 'serve', 'watch']