-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
66 lines (52 loc) · 1.94 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
gulp = require('gulp')
coffee = require('gulp-coffee')
livereload = require('gulp-livereload')
# CSS
stylus = require('gulp-stylus')
nib = require('nib')
csso = require('gulp-csso')
# Utils
chalk = require('chalk')
dateformat = require('dateformat')
plumber = require('gulp-plumber')
fs = require('fs')
outputFolder = './app/wp-content/themes/bigpixel'
log = ->
time = '[' + chalk.magenta(dateformat(new Date(), 'HH:MM:ss')) + ']'
args = Array::slice.call(arguments)
args.unshift time
console.log.apply console, args
return this
filePathShort = (filePath)->
filePath.replace(__dirname, '')
# Watch
# #########################
gulp.task 'watch', ['build'], ->
livereload.listen({auto: true})
# Watch style changes
watcher_style = gulp.watch('./src/css/**/*', ['development-styles'])
watcher_style.on 'change', (e)->
log e.type + ' ' + chalk.yellow(filePathShort(e.path))
# Development
# #########################
gulp.task 'development-styles', ->
gulp.src './src/css/application.styl'
.pipe plumber()
.pipe stylus({use: [nib()], linenos: true, 'include css': true, url: {name: 'url', limit: 32768, paths: [outputFolder + '/img']}})
.pipe gulp.dest "#{outputFolder}/css"
.pipe livereload auto: false
# Build
# #########################
gulp.task 'build', ['build-styles']
gulp.task 'build-styles', ['build-styles-files', 'build-style-editor'], ->
gulp.src "#{outputFolder}/css/application.css"
.pipe gulp.dest "#{outputFolder}/css/"
gulp.task 'build-styles-files', ->
gulp.src './src/css/application.styl'
.pipe stylus({use: [nib()], 'include css': true, url: {name: 'url', limit: 32768, paths: [outputFolder + '/img']}})
.pipe(csso(false))
.pipe gulp.dest "#{outputFolder}/css"
gulp.task 'build-style-editor', ->
gulp.src './src/css/editor-style.styl'
.pipe stylus({use: [nib()], 'include css': true, url: {name: 'url', limit: 32768, paths: [outputFolder + '/img']}})
.pipe gulp.dest "#{outputFolder}"