/
gulpfile.coffee
93 lines (79 loc) · 2.38 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
"use strict"
gulp = require 'gulp'
gutil = require "gulp-util"
bower = require 'main-bower-files'
browserSync = require "browser-sync"
spritesmith = require 'gulp.spritesmith'
isRelease = gutil.env.release?
$ = require("gulp-load-plugins")()
$public = "./public"
$src = "./src"
$server = "./src/server"
$client = "./src/client"
config =
path:
public: $public
server: $server+"/app.coffee"
stylus: $client+"/stylesheets/**/*.styl"
coffee: $client+"/javascripts/**/*.coffee"
jade: $client+"/views/**/*.jade"
images: [$client + '/images/**/*.*', '!'+$client+'/**/*.ico' ,'!'+$client+'/images/**/*.svg']
outpath:
stylus: $public+'/assets/stylesheets/'
coffee: $public+'/assets/javascripts/'
bower: $public+'/assets/libs'
# ブラウザーシンク起動
gulp.task "browser-sync",->
browserSync.init null,{
proxy: "http://localhost:9000"
port: 5000
}
gulp.task "browser-sync-reload",->
browserSync.reload()
# サーバ起動
gulp.task "nodemon",(callback)->
return $.nodemon({
script: config.path.server
})
# cssの生成
gulp.task 'stylus', ['sprite_stylus'], ->
gulp.src(config.path.stylus)
.pipe $.plumber({errorHandler: $.notify.onError("<%= error.message %>")})
.pipe $.stylus()
.pipe gulp.dest(config.outpath.stylus)
# coffeeの生成
gulp.task 'coffee', ->
gulp.src(config.path.coffee)
.pipe $.plumber({errorHandler: $.notify.onError("<%= error %>")})
.pipe $.coffee()
.pipe gulp.dest(config.outpath.coffee)
#bowerコンポーネンツあたり
gulp.task 'bower', ->
gulp.src(bower())
.pipe $.if isRelease, $.uglify({preserveComments:'some'})
.pipe $.flatten()
.pipe (gulp.dest config.outpath.bower)
gulp.task 'sprite_stylus', ->
spriteDataStylus = gulp.src config.path.images
.pipe spritesmith({
imgName: 'sprite.png'
cssName: 'sprite.styl'
cssFormat: 'stylus'
imgPath: 'sprite.png'
destCSS: config.path.stylesheets
engine: 'gm'
})
spriteDataStylus.img.pipe(gulp.dest('public/stylesheets/'));
spriteDataStylus.css.pipe(gulp.dest('public/stylesheets/'));
gulp.task "watch", ()->
gulp.watch config.path.stylus,["stylus","browser-sync-reload"]
gulp.watch config.path.coffee,["coffee","browser-sync-reload"]
gulp.watch config.path.jade,["browser-sync-reload"]
gulp.task "default",[
"bower"
"nodemon"
"browser-sync"
"stylus"
"coffee"
"watch"
],->