-
Notifications
You must be signed in to change notification settings - Fork 19
/
gruntfile.coffee
252 lines (223 loc) · 7.07 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
module.exports = (grunt) ->
# Configurable paths.
yeomanConfig =
app: 'app'
dist: 'dist'
test: 'test'
coverage: 'coverage'
tmp: '.tmp'
# Show elapsed time at the end.
if grunt.option 'timing'
(require 'time-grunt') grunt
# Load all grunt tasks.
(require 'load-grunt-tasks') grunt
grunt.initConfig
yeoman: yeomanConfig
watch:
options:
spawn: false
coffeelint:
files: [
'*.coffee'
'<%= yeoman.test %>/*.coffee'
'<%= yeoman.app %>/scripts/*.coffee'
]
tasks: [
'coffee'
'coffeelint'
'karma:watch:run'
]
jsonlint:
files: [
'*.json'
'.*rc'
'<%= yeoman.app %>/*.json'
'<%= yeoman.test %>/fixtures/*.json'
]
tasks: [
'jsonlint'
'karma:watch:run'
]
csslint:
files: ['<%= yeoman.app %>/styles/*.css']
tasks: ['csslint']
clean:
dist:
files: [
dot: true
src: [
'<%= yeoman.dist %>/*'
'!<%= yeoman.dist %>/.git*'
]
]
coverage: ['<%= yeoman.coverage %>']
tmp: ['<%= yeoman.tmp %>']
compress: ['zip/TabAhead.zip']
coffee:
src: ['<%= yeoman.app %>/scripts/*{.js,.js.map}']
coffeelint:
options:
configFile: 'coffeelint.json'
all: [
'*.coffee',
'<%= yeoman.test %>/*.coffee'
'<%= yeoman.app %>/scripts/*.coffee'
]
jsonlint:
all: [
'*.json'
'.bower_rc'
'.coffeelintrc'
'<%= yeoman.app %>/*.json'
'<%= yeoman.test %>/fixtures/*.json'
]
csslint:
options:
csslintrc: '.csslintrc'
all: ['<%= yeoman.app %>/styles/*.css']
coffee:
options:
sourceMap: true
transpile:
presets: ['env']
compile:
expand: true
flatten: true
cwd: '<%= yeoman.app %>/scripts'
src: ['*.coffee']
dest: '<%= yeoman.app %>/scripts'
ext: '.js'
karma:
options:
configFile: 'karma.conf.coffee'
e2e: {}
watch:
browsers: ['Chrome']
autoWatch: false
background: true
singleRun: false
useminPrepare:
options:
dest: '<%= yeoman.dist %>'
html: [
'<%= yeoman.app %>/popup.html'
'<%= yeoman.app %>/options.html'
]
usemin:
options:
dirs: ['<%= yeoman.dist %>']
staging: '<%= yeoman.tmp %>'
html: ['<%= yeoman.dist %>/{,*/}*.html']
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
imagemin:
dist:
files: [
expand: true
cwd: '<%= yeoman.app %>/images'
src: '{,*/}*.{png,jpg,jpeg}'
dest: '<%= yeoman.dist %>/images'
]
htmlmin:
dist:
options:
# https://github.com/yeoman/grunt-usemin/issues/44
# collapseWhitespace: true
collapseBooleanAttributes: true
useShortDoctype: true
removeEmptyAttributes: true
files: [
expand: true
cwd: '<%= yeoman.app %>'
src: '*.html'
dest: '<%= yeoman.dist %>'
]
# Put files not handled in other tasks here
copy:
dist:
files:
'<%= yeoman.dist %>/LICENSE': [
'LICENSE'
]
'<%= yeoman.dist %>/manifest.json': [
'<%= yeoman.app %>/manifest.json'
]
'<%= yeoman.dist %>/images/insert-coins-ff7700.svg': [
'<%= yeoman.app %>/images/insert-coins-ff7700.svg'
]
purifycss:
popup:
src: [
'<%= yeoman.app %>/popup.html'
'<%= yeoman.tmp %>/concat/scripts/popup.js'
],
css: ['<%= yeoman.tmp %>/concat/styles/main.css']
dest: '<%= yeoman.tmp %>/concat/styles/main.css'
options_page:
src: [
'<%= yeoman.app %>/options.html'
'<%= yeoman.tmp %>/concat/scripts/options.js'
],
css: ['<%= yeoman.tmp %>/concat/styles/options.css']
dest: '<%= yeoman.tmp %>/concat/styles/options.css'
concurrent:
test: [
'coffeelint'
'jsonlint'
'csslint'
'karma:e2e'
]
dist: [
'imagemin'
'htmlmin'
]
compress:
dist:
options:
archive: 'zip/TabAhead.zip'
files: [
expand: true
cwd: 'dist/'
src: ['**']
dest: ''
]
updateVersion:
all: [
'<%= yeoman.app %>/manifest.json'
'package.json'
'bower.json'
]
shell:
coveralls:
command: 'cat <%= yeoman.coverage %>/*/lcov.info | ./node_modules/coveralls/bin/coveralls.js'
grunt.registerMultiTask 'updateVersion',
'Update the version key of .json files.', ->
versionnumber = grunt.option 'versionnumber'
error = 'Use --versionnumber flag to specify the new version number.'
grunt.log.error(error) unless versionnumber?
@filesSrc.forEach (filepath) ->
manifest = grunt.file.readJSON filepath
manifest.version = versionnumber
grunt.file.write filepath, JSON.stringify manifest, null, 2
grunt.registerTask 'test', [
'concurrent:test'
]
grunt.registerTask 'build', [
'test'
'coffee'
'clean:dist'
'useminPrepare'
'concurrent:dist'
'concat'
'purifycss'
'cssmin'
'uglify'
'copy'
'usemin'
'clean:compress'
'compress'
]
grunt.registerTask 'default', [
'build'
'karma:watch'
'watch'
]