-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.coffee
332 lines (285 loc) · 7.81 KB
/
Gruntfile.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
module.exports = (grunt) ->
# show elapsed time at the end
require("time-grunt") grunt
# load all grunt tasks
require("load-grunt-tasks") grunt
grunt.initConfig
# grunt nodemon setup: https://github.com/ChrisWren/grunt-nodemon#advanced-usage
concurrent:
dev:
tasks: [
"nodemon"
# "node-inspector" # might want to add this back
'watch:server'
'watch:scripts'
'watch:css'
'watch:sass'
'watch:images'
]
options:
logConcurrentOutput: true
dist: [
"sass:dev"
"copy:styles"
"copy:fonts"
"svgmin"
"htmlmin"
]
test:
tasks: [
"karma:unit"
"watch:mocha"
]
options:
logConcurrentOutput: true
nodemon:
dev:
script: "app.coffee"
options:
# nodeArgs: ["--debug"]
env:
PORT: "1337"
# omit this property if you aren't serving HTML files and
# don't want to open a browser tab on start
callback: (nodemon) ->
nodemon.on "log", (event) ->
console.log event.colour
return
# # opens browser on initial server start
# nodemon.on "config:update", ->
#
# # Delay before server listens on port
# setTimeout (->
# require("open") "http://localhost:5455"
# return
# ), 1000
# return
# refreshes browser when server reboots
nodemon.on "restart", ->
# Delay before server listens on port
setTimeout (->
require("fs").writeFileSync ".rebooted", "rebooted"
return
), 1000
return
return
watch:
server:
files: [".rebooted"]
options:
livereload: true
scripts:
files: ["assets/scripts/**/*.js", "src/**/*.coffee"]
css:
files: ["assets/styles/**/*.css"]
sass:
files: ["assets/styles/**/*.scss"]
tasks: ["sass:dev"]
images:
files: ["assets/images/**/*.{png,jpg,jpeg,webp}"]
mocha:
options:
spawn: false # faster reloading
files: ['test/src/**/*.coffee', 'test/routes/**/*.coffee', 'src/**/*.coffee', 'routes/**/*.coffee']
tasks: ['mochaTest:test']
karma:
unit:
configFile: 'karma.conf.js'
autoWatch: true
mochaTest:
test:
options:
clearRequireCache: true # for spawn: false tests (https://github.com/pghalliday/grunt-mocha-test#running-in-permanent-environments-like-watch)
reporter: 'spec'
require: ['coffee-script/register', 'test/test_helper.coffee']
recursive: true
timeout: 5000
src: ['test/src/**/*.coffee', 'test/routes/**/*.coffee']
clean:
dist:
files: [
dot: true
src: [
".tmp"
"dist/*"
"!dist/.git*"
]
]
server: [".tmp"]
jshint:
options:
jshintrc: ".jshintrc"
all: [
"Gruntfile.js"
"assets/scripts/**/*.js"
"!assets/scripts/vendor/*"
"test/spec/**/*.js"
]
sass: # task
options:
bundleExec: true
dev: # another target
# options: # dictionary of render options
# sourceMap: true
files:
'assets/styles/screen.css': 'assets/styles/sass/screen.scss'
# dist: # target
# files: # dictionary of files
# 'assets/styles/screen.css': 'assets/styles/screen.scss' # 'destination': 'source'
express:
options:
# Override defaults here
opts: ["node_modules/coffee-script/bin/coffee"]
port: 1337
dev:
options:
script: "app.coffee"
open:
site:
path: "http://localhost:1337"
app: "Google Chrome"
editor:
path: "./"
app: "atom"
rev:
dist:
files:
src: [
"dist/assets/scripts/**/*.js"
"dist/assets/styles/**/*.css"
"dist/assets/images/**/*.{png,jpg,jpeg,gif,webp}"
"dist/assets/styles/fonts/**/*.*"
]
useminPrepare:
options:
dest: "dist/assets"
html: [
"assets/{,*/}*.html"
"views/**/*.handlebars"
]
usemin:
options:
dirs: ["dist/assets"]
basedir: "dist/assets"
html: [
"dist/assets/{,*/}*.html"
"dist/views/**/*.handlebars"
]
css: ["dist/assets/styles/{,*/}*.css"]
imagemin:
dist:
files: [
expand: true
cwd: "assets/images"
src: "**/*.{png,jpg,jpeg}"
dest: "dist/assets/images"
]
svgmin:
dist:
files: [
expand: true
cwd: "assets/images"
src: "{,*/}*.svg"
dest: "dist/assets/images"
]
cssmin: {}
# This task is pre-configured if you do not wish to use Usemin
# blocks for your CSS. By default, the Usemin block from your
# `index.html` will take care of minification, e.g.
#
# <!-- build:css({.tmp,app}) styles/main.css -->
#
# dist: {
# files: {
# 'dist/assets/styles/main.css': [
# '.tmp/styles/{,*/}*.css',
# 'assets/styles/{,*/}*.css'
# ]
# }
# }
#
htmlmin:
dist:
options: {}
#removeCommentsFromCDATA: true,
# // https://github.com/yeoman/grunt-usemin/issues/44
# //collapseWhitespace: true,
# collapseBooleanAttributes: true,
# removeAttributeQuotes: true,
# removeRedundantAttributes: true,
# useShortDoctype: true,
# removeEmptyAttributes: true,
# removeOptionalTags: true
files: [
expand: true
cwd: "assets"
src: "*.html"
dest: "dist/assets"
]
env:
options: {}
dev:
NODE_ENV: "DEVELOPMENT"
prod:
NODE_ENV: "PRODUCTION"
preprocess:
js:
src: "./assets/scripts/main_preprocess.js"
dest: "./assets/scripts/main.js"
# Put files not handled in other tasks here
copy:
dist:
files: [
{
expand: true
dot: true
cwd: "assets"
dest: "dist/assets"
src: [
"*.{ico,png,txt}"
".htaccess"
"images/**/*.{webp,gif}"
"styles/fonts/{,*/}*.*"
]
}
{
expand: true
dot: true
cwd: "views"
dest: "dist/views/"
src: "**/*.handlebars"
}
]
styles:
expand: true
dot: true
cwd: "assets/styles"
dest: ".tmp/styles/"
src: "{,*/}*.css"
fonts:
expand: true
flatten: true
filter: 'isFile'
src: ['assets/bower_components/components-font-awesome/fonts/**']
dest: 'dist/assets/fonts'
# Register Tasks
grunt.registerTask "dev", "Start our development environment", [
"env:dev" # set ENV vars
"preprocess:js" # process main.js for ENV vars
"concurrent:dev"
]
grunt.registerTask "build", "Build production ready assets and views.", [
"env:prod"
"preprocess:js"
"clean:dist"
"concurrent:dist"
"useminPrepare"
"imagemin"
"concat"
"cssmin"
"uglify"
"copy:dist"
"rev"
"usemin"
]
return