forked from Julusian/react-bootstrap-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.coffee
More file actions
132 lines (116 loc) · 3.8 KB
/
gulpfile.coffee
File metadata and controls
132 lines (116 loc) · 3.8 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
gulp = require 'gulp'
$ = require('gulp-load-plugins') lazy: false
server = require('browser-sync').create()
reload = server.reload
extend = require('util')._extend
karma = require('karma').server
karmaConfig = require './karma.json'
pkg = require './package.json'
name = pkg.name
cleanCss = require 'less-plugin-clean-css'
cleanCss = new cleanCss advanced: true
paths =
base: './'
src: 'src'
dist: 'dist'
test: 'test'
components: "components"
src =
scripts: "#{paths.src}/coffee/#{name}.coffee"
stylesheets:
bootstrap2: "#{paths.src}/less/bootstrap2/build.less"
bootstrap3: "#{paths.src}/less/bootstrap3/build.less"
test: "#{paths.src}/coffee/#{name}.tests.coffee"
dest =
scripts: "#{paths.dist}/js"
stylesheets:
bootstrap2: "#{paths.dist}/css/bootstrap2"
bootstrap3: "#{paths.dist}/css/bootstrap3"
test: paths.test
banner = """
/* ========================================================================
* <%= pkg.name %> - v<%= pkg.version %>
* <%= pkg.homepage %>
* ========================================================================
* Copyright 2012-2015 <%= pkg.author.name %>
*
* Released under the MIT license
* ========================================================================
*/
"""
# build
gulp.task 'coffee', ->
gulp
.src src.scripts
.pipe $.plumber errorHandler: $.notify.onError "Error: <%= error.message %>"
.pipe $.changed dest.scripts
.pipe $.coffeelint 'coffeelint.json'
.pipe $.coffeelint.reporter()
.pipe $.coffeelint.reporter("fail")
.pipe $.cjsx()
.on 'error', $.util.log
.pipe $.header banner, pkg: pkg
.pipe gulp.dest dest.scripts
.pipe gulp.dest dest.test
.pipe $.uglify()
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest dest.scripts
gulp.task 'less-bootstrap2', ->
gulp
.src src.stylesheets.bootstrap2
.pipe $.plumber errorHandler: $.notify.onError "Error: <%= error.message %>"
.pipe $.changed dest.stylesheets.bootstrap2
.pipe $.less()
.on 'error', $.util.log
.pipe $.header banner, pkg: pkg
.pipe $.rename basename: name
.pipe gulp.dest dest.stylesheets.bootstrap2
.pipe $.less plugins: [cleanCss]
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest dest.stylesheets.bootstrap2
gulp.task 'less-bootstrap3', ->
gulp
.src src.stylesheets.bootstrap3
.pipe $.plumber errorHandler: $.notify.onError "Error: <%= error.message %>"
.pipe $.changed dest.stylesheets.bootstrap3
.pipe $.less()
.pipe $.header banner, pkg: pkg
.pipe $.rename basename: name
.pipe gulp.dest dest.stylesheets.bootstrap3
.pipe $.less plugins: [cleanCss]
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest dest.stylesheets.bootstrap3
# test
gulp.task 'test-coffee', ['coffee'], ->
gulp
.src src.test
.pipe $.plumber errorHandler: $.notify.onError "Error: <%= error.message %>"
.pipe $.changed dest.test
.pipe $.coffeelint 'coffeelint.json'
.pipe $.coffeelint.reporter()
.pipe $.coffeelint.reporter("fail")
.pipe $.coffee()
.on 'error', $.util.log
.pipe gulp.dest dest.test
gulp.task 'test-go', ['test-coffee'], (done) ->
karma.start extend(karmaConfig, singleRun: true), done
# extra
gulp.task 'watch', [], ->
gulp.watch src.scripts, ['coffee']
gulp.watch src.stylesheets.bootstrap2, ['less-bootstrap2']
gulp.watch src.stylesheets.bootstrap3, ['less-bootstrap3']
gulp.watch('package.json', ['dist']).on 'change', -> pkg = require './package.json'
gulp.watch [
"#{dest.scripts}/*.js"
"#{dest.stylesheets.bootstrap2}/*.css"
"#{dest.stylesheets.bootstrap3}/*.css"
"*.html"
]
.on 'change', reload
gulp.task 'less', ['less-bootstrap2', 'less-bootstrap3']
gulp.task 'dist', ['coffee', 'less']
gulp.task 'test', ['coffee', 'test-coffee', 'test-go']
gulp.task 'default', ['dist', 'watch']