-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
84 lines (71 loc) · 1.7 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
gulp = require 'gulp'
plumber = require 'gulp-plumber'
sass = require 'gulp-sass'
sourcemaps = require 'gulp-sourcemaps'
pleeease = require 'gulp-pleeease'
webpack = require 'gulp-webpack'
browserSync = require 'browser-sync'
#
# SCSS (with AutoPrefixer, minify, SourceMaps)
#
gulp.task 'styles', ->
gulp.src './src/styles/*.scss'
.pipe plumber()
.pipe sourcemaps.init()
.pipe sass().on 'error', sass.logError
.pipe pleeease()
.pipe sourcemaps.write '.'
.pipe gulp.dest './assets/css/'
#
# webpack (CoffeeScript, require, SourceMaps, Uglify)
#
gulp.task 'scripts', ->
gulp.src './src/scripts/script.coffee'
.pipe plumber()
.pipe webpack
entry:
script: './src/scripts/script.coffee'
output:
filename: '[name].js'
publicPath: '/assets/js/'
resolve:
extensions: ['', '.js', '.coffee']
modulesDirectories: [ 'src/scripts', 'node_modules', 'bower_components' ],
plugins: [
new webpack.webpack.optimize.UglifyJsPlugin()
]
module:
loaders: [
{ test: /\.coffee$/, loader: 'coffee-loader' }
]
devtool: 'source-map'
.pipe gulp.dest './assets/js'
#
# build assets (css, javascript)
#
gulp.task 'build', ['styles', 'scripts']
#
# Watch
#
gulp.task 'watch', ->
gulp.watch 'src/styles/**/*.scss', ['styles']
gulp.watch 'src/scripts/**/*.+(js|coffee)', ['scripts']
#
# start BrowserSync / LiveReload
#
gulp.task 'serve', ['watch'], ->
browserSync
notify: false,
port: 9000,
server:
baseDir: '.'
gulp.watch [
'**/*.html'
'**/*.php'
'assets/**/*'
]
.on 'change', browserSync.reload
#
# default
#
gulp.task 'default', ['build', 'serve']