/
Gruntfile.coffee
143 lines (131 loc) · 3.75 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
# If you're new to [Grunt](http://gruntjs.com) then get yourself over to the
# ['getting started'](http://gruntjs.com/getting-started) section on their site.
module.exports = (grunt) ->
# To keep this file as minimal as possible the [NPM](http://npmjs.org) tasks are stored in the `./grunt/` folder as
# individual files for each task.
grunt.loadTasks 'grunt'
# ## grunt install
# This task installs the bower dependancies.
grunt.registerTask 'install', 'install bower dependancies', () ->
done = @async()
config =
cmd: 'bower'
args: [
'install'
]
child = grunt.util.spawn config, (err, result) ->
grunt.log.ok 'Installed bower dependancies'
done()
child.stdout.on 'data', (data) ->
grunt.log.write data
# ## grunt githash
# This task creates a Grunt config variable called `git-commit` that contains the latest git commit sha1 hash.
grunt.registerTask 'githash', 'grabs the latest git commit hash', () ->
done = @async()
config =
cmd: 'git'
args: [
'rev-parse'
'--verify'
'HEAD'
]
grunt.util.spawn config, (err, result) ->
# To deal with cache busting this task grabs the latest git commit sha1 and uses this for naming the optimised
# CSS and JS files.
grunt.config 'git-commit', result.stdout
grunt.log.ok "Setting `git-commit` to #{result.stdout}"
done()
# ## grunt default
# This task is useful for running whilst you're developing your app. It installs the [Bower](http://bower.io)
# dependancies, runs the development preprocessor tasks, starts the local express server and watches your files
# as you code your awsome app.
grunt.registerTask 'default', 'run the server and watch for changes', [
'githash'
'install'
'sprite'
'compass:devSASS'
# 'compass:devSCSS'
# 'less:dev'
# 'stylus:dev'
'coffee:dev'
'jade:dev'
'express'
'watch'
]
# ## grunt test
# This task runs both the unit and e2d tests.
grunt.registerTask 'test', 'compile the app and run the tests', [
'githash'
'install'
'sprite'
'compass:devSASS'
# 'compass:devSCSS'
# 'less:dev'
# 'stylus:dev'
# 'jshint'
# 'jscs'
'coffeelint'
'coffee:dev'
'jade:dev'
'karma'
'coffee:e2e'
'express'
'exec:e2e'
]
# ## grunt unit
# This task runs the unit tests in [karma](http://karma-runner.github.io).
grunt.registerTask 'unit', 'run unit tests', [
'githash'
'install'
# 'jshint'
# 'jscs'
'coffeelint'
'coffee:dev'
'jade:dev'
'karma'
]
# ## grunt e2e
# This task runs the e2e tests in [protractor](https://github.com/angular/protractor).
grunt.registerTask 'e2e', 'run e2e tests', [
'githash'
'install'
'sprite'
'compass:devSASS'
# 'compass:devSCSS'
# 'less:dev'
# 'stylus:dev'
# 'jshint'
# 'jscs'
'coffeelint'
'coffee:dev'
'coffee:e2e'
'jade:dev'
'express'
'exec:e2e'
]
# ## grunt build
# This task builds the app. It starts by running all the preprocessors in production mode, compressing the images
# and packages up the app using the awesome [`r.js`](http://requirejs.org/docs/optimization.html) optimiser.
# It then copies files into place (by default into the `./build/` directory) and replaces the bower libraries with
# CDN versions. Finally it executes the crawler to make the app SEO friendly.
grunt.registerTask 'build', 'build and package the app', [
'clean'
'githash'
'install'
'sprite'
'imagemin'
'compass:prodSASS'
# 'compass:prodSCSS'
# 'less:prod'
# 'stylus:prod'
'cmq'
'cssmin'
'coffee:prod'
'jade:prod'
'ngtemplates'
'requirejs'
'copy'
'express'
'exec:crawl'
'replace'
]