This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
forked from gudh/ihover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
executable file
·294 lines (257 loc) · 9.53 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
"use strict"
LIVERELOAD_PORT = 35728
lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT)
# var conf = require('./conf.'+process.env.NODE_ENV);
mountFolder = (connect, dir) ->
connect.static require("path").resolve(dir)
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
require("load-grunt-tasks") grunt
require("time-grunt") grunt
# configurable paths
yeomanConfig =
app: "client"
dist: "dist"
try
yeomanConfig.app = require("./bower.json").appPath or yeomanConfig.app
grunt.initConfig
yeoman: yeomanConfig
watch:
coffee:
files: ["<%= yeoman.app %>/scripts/**/*.coffee"]
tasks: ["coffee:dist"]
# less:
# files: ["<%= yeoman.app %>/styles/**/*.less"]
# tasks: ["less:server"]
compass:
files: ["<%= yeoman.app %>/styles/**/*.scss"]
tasks: ["compass:server"]
jade:
files: ["<%= yeoman.app %>/templates/*.jade"]
tasks: ["jade:server"]
livereload:
options:
livereload: LIVERELOAD_PORT
files: [
"<%= yeoman.app %>/templates/*.jade"
# "<%= yeoman.app %>/styles/**/*.less"
"<%= yeoman.app %>/styles/**/*.scss"
".tmp/styles/**/*.css"
"{.tmp,<%= yeoman.app %>}/scripts/**/*.js"
"{.tmp,<%= yeoman.app %>}/scripts/**/*.coffee"
"<%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}"
]
connect:
options:
port: 9000
# Change this to '0.0.0.0' to access the server from outside.
hostname: "localhost"
livereload:
options:
middleware: (connect) ->
[lrSnippet, mountFolder(connect, ".tmp"), mountFolder(connect, yeomanConfig.app)]
test:
options:
middleware: (connect) ->
[mountFolder(connect, ".tmp"), mountFolder(connect, "test")]
dist:
options:
middleware: (connect) ->
[mountFolder(connect, yeomanConfig.dist)]
open:
server:
url: "http://localhost:<%= connect.options.port %>"
clean:
dist:
files: [
dot: true
src: [".tmp", "<%= yeoman.dist %>/*", "!<%= yeoman.dist %>/.git*"]
]
server: ".tmp"
jshint:
options:
jshintrc: ".jshintrc"
all: ["Gruntfile.js", "<%= yeoman.app %>/scripts/**/*.js"]
jade:
server:
options:
pretty: true
files: [
expand: true
cwd: "<%= yeoman.app %>/templates"
src: [
"*.jade"
"!layout.jade"
]
dest: "<%= yeoman.app %>/"
ext: ".html"
]
dist:
options:
pretty: true
files: [
expand: true
cwd: "<%= yeoman.app %>/templates"
src: [
"*.jade"
"!layout.jade"
]
dest: "<%= yeoman.app %>/"
ext: ".html"
]
# less:
# server:
# options:
# strictMath: true
# dumpLineNumbers: true
# sourceMap: true
# sourceMapRootpath: ""
# outputSourceFiles: true
# files: [
# expand: true
# cwd: "<%= yeoman.app %>/styles"
# src: ["ihover.less", "docs-overrides.less"]
# dest: ".tmp/styles"
# ext: ".css"
# ]
# min:
# options:
# strictMath: true
# compress: true
# sourceMapRootpath: ""
# outputSourceFiles: true
# files: [
# expand: true
# cwd: "<%= yeoman.app %>/styles"
# src: "ihover.less"
# dest: ".tmp/styles"
# ext: ".css"
# ]
# dist:
# options:
# cleancss: true,
# report: 'min'
# files:
# '.tmp/styles/ihover.css': '<%= yeoman.app %>/styles/ihover.less'
# '.tmp/styles/docs-overrides.css': '<%= yeoman.app %>/styles/docs-overrides.less'
compass:
options:
sassDir: "<%= yeoman.app %>/styles"
cssDir: ".tmp/styles"
generatedImagesDir: ".tmp/assets/"
imagesDir: "<%= yeoman.app %>/assets"
javascriptsDir: "<%= yeoman.app %>/scripts"
fontsDir: "<%= yeoman.app %>/fonts"
importPath: "<%= yeoman.app %>/bower_components"
httpImagesPath: "/assets"
httpGeneratedImagesPath: "/assets"
httpFontsPath: "/fonts"
relativeAssets: true
dist:
options:
noLineComments: true
debugInfo: false
outputStyle: 'expanded'
min:
options:
noLineComments: true
debugInfo: false
outputStyle: 'compressed'
server:
options:
debugInfo: true
# if you want to use the compass config.rb file for configuration:
# compass:
# dist:
# options:
# config: 'config.rb'
coffee:
server:
options:
sourceMap: true
# join: true,
sourceRoot: ""
files: [
expand: true
cwd: "<%= yeoman.app %>/scripts"
src: "**/*.coffee"
dest: ".tmp/scripts"
ext: ".js"
]
dist:
options:
sourceMap: false
# join: true,
sourceRoot: ""
files: [
expand: true
cwd: "<%= yeoman.app %>/scripts"
src: "**/*.coffee"
dest: ".tmp/scripts"
ext: ".js"
]
useminPrepare:
html: "<%= yeoman.app %>/index.html"
options:
dest: "<%= yeoman.dist %>"
flow:
steps:
'css': ["concat"]
'js': ["concat"]
post: []
usemin:
html: ["<%= yeoman.dist %>/**/*.html", "!<%= yeoman.dist %>/bower_components/**"]
css: ["<%= yeoman.dist %>/styles/**/*.css"]
options:
dirs: ["<%= yeoman.dist %>"]
htmlmin:
dist:
options: {}
files: [
expand: true
cwd: "<%= yeoman.app %>"
src: ["*.html", "views/*.html"]
dest: "<%= yeoman.dist %>"
]
# Put files not handled in other tasks here
copy:
dist:
files: [
expand: true
dot: true
cwd: "<%= yeoman.app %>"
dest: "<%= yeoman.dist %>"
src: [
"fonts/**/*"
"images/**/*"
]
]
styles:
expand: true
cwd: "<%= yeoman.app %>/styles"
dest: ".tmp/styles/"
src: "**/*.css"
concurrent:
server: ["coffee:server", "jade:server", "compass:server", "copy:styles"]
dist: ["coffee:dist", "jade:dist", "compass:dist", "copy:styles", "htmlmin"]
concat:
options:
separator: grunt.util.linefeed + ';' + grunt.util.linefeed
dist:
src: ["<%= yeoman.dist %>/jquery/jquery.min.js"]
dest: "<%= yeoman.dist %>/scripts/app.js"
#
# 'concat', 'uglify' not need, "usemin" with take care of them
# uglify:
# dist:
# files:
# "<%= yeoman.dist %>/scripts/app.js": [".tmp/**/*.js"]
grunt.registerTask "server", (target) ->
return grunt.task.run(["build", "open", "connect:dist:keepalive"]) if target is "dist"
grunt.task.run ["clean:server", "concurrent:server", "connect:livereload", "open", "watch"]
grunt.registerTask "build", ["clean:dist", "jade:server", "useminPrepare", "concurrent:dist", "copy:dist", "concat", "usemin"]
grunt.registerTask "default", ["jshint", "build"]