-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.coffee
218 lines (186 loc) · 4.87 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
'use strict'
module.exports = (grunt) ->
require('load-grunt-tasks') grunt
require('time-grunt') grunt
grunt.initConfig
app:
app: 'app'
dist: 'www'
hoodieCfg: {}
hoodie: start: options: callback: (cfg) ->
grunt.config.set 'hoodieCfg', cfg
grunt.config.set 'connect.livereload.proxies', [
context: '/_api'
host: cfg.stack.www.host
port: cfg.stack.www.port
]
watch:
options:
livereload: '<%= connect.options.livereload %>'
js:
files: ['<%= app.app %>/scripts/**/*.js']
tasks: ['jshint:watch']
styles:
files: ['.tmp/styles/main.css']
view:
files: ['<%= app.app %>/index.html', '<%= app.app %>/views/**/*.html']
less:
options:
livereload: off
files: ['<%= app.app %>/styles/**/*.less']
tasks: ['less:styles']
gruntfile:
files: ['Gruntfile.{js,coffee}']
connect:
options:
port: 9000
hostname: '0.0.0.0'
livereload: 35729
middleware: (connect, options) ->
unless Array.isArray options.base
options.base = [options.base]
middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest]
options.base.forEach (base) -> middlewares.push connect.static base
directory = options.directory or options.base[options.base.length - 1]
middlewares.push connect.directory directory
middlewares
livereload:
options:
open: true
base: [
'.tmp'
'<%= app.app %>'
]
# proxies: set by hoodie
dist:
options:
base: '<%= app.dist %>'
jshint:
options:
jshintrc: '.jshintrc'
watch: [ '<%= app.app %>/scripts/**/*.js' ]
uglify: options:
preserveComments: 'some'
clean:
dist:
files: [
dot: true
src: [
'.tmp'
'<%= app.dist %>/*'
'!<%= app.dist %>/.git*'
]
]
server: '.tmp'
useminPrepare:
html: '<%= app.app %>/index.html'
options:
dest: '<%= app.dist %>'
rev:
dist:
files:
src: [
'<%= app.dist %>/scripts/**/*.js'
'<%= app.dist %>/styles/**/*.css'
]
usemin:
html: ['<%= app.dist %>/**/*.html']
css: ['.tmp/styles/**/*.css']
options:
assetsDirs: ['<%= app.dist %>']
manifest:
generate:
options:
basePath: '<%= app.dist %>'
preferOnline: yes
verbose: no
cache: ['/_api/_files/hoodie.js']
src: [
'package.json'
'scripts/*.js'
'styles/*.css'
'fonts/*'
]
dest: '<%= app.dist %>/manifest.appcache'
ngtemplates:
zentodone:
cwd: '<%= app.app %>'
src: 'views/*.html'
dest: '.tmp/templates.js'
options:
htmlmin:
collapseBooleanAttributes: on
collapseWhitespace: off
removeAttributeQuotes: on
removeComments: on
removeEmptyAttributes: on
removeRedundantAttributes: on
removeScriptTypeAttributes: on
removeStyleLinkTypeAttributes: on
usemin: '<%= app.dist %>/scripts/app.js'
ngmin:
dist:
files: [
expand: true
cwd: '<%=app.app%>/scripts'
src: '**/*.js'
dest: '.tmp/scripts'
]
less:
styles:
src: ['<%=app.app%>/styles/main.less']
dest: '.tmp/styles/main.css'
copy:
dist:
files: [
expand: true
dot: true
cwd: '<%= app.app %>'
dest: '<%= app.dist %>'
src: [
'fonts/*'
'../package.json'
'*.{png,ico,xml}'
'index.html'
]
,
'<%= app.dist %>/package.json': 'package.json'
]
concurrent:
dist: ['less:styles', 'ngmin']
bump: options:
commitMessage: 'chore(release): v%VERSION%'
files: ['package.json', 'bower.json']
commitFiles: ['package.json', 'bower.json', 'CHANGELOG.md']
pushTo: 'origin master'
grunt.registerTask 'release', ->
@args.unshift 'bump-only'
grunt.task.run [
@args.join ':'
'changelog'
'bump-commit'
]
grunt.registerTask 'serve', [
'clean:server'
'hoodie'
'less:styles'
'connect:livereload'
'configureProxies:livereload'
'watch'
]
# TODO: remove "continueOn" hack to work around https://github.com/yeoman/grunt-usemin/issues/291
grunt.registerTask 'build', [
'clean'
'concurrent'
'useminPrepare'
'ngtemplates'
'copy'
'concat'
'uglify'
'cssmin'
'rev'
'usemin'
'manifest'
]
grunt.registerTask 'test', ['jshint', 'build']
grunt.registerTask 'default', ['build']