-
Notifications
You must be signed in to change notification settings - Fork 11
/
Gruntfile.coffee
212 lines (172 loc) · 5.51 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
"use strict"
LIVERELOAD_PORT = 35728
lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT)
mountFolder = (connect, dir) ->
connect.static require("path").resolve(dir)
module.exports = (grunt) ->
# Load all grunt tasks
matchdep = require("matchdep")
matchdep.filterDev("grunt-*").forEach grunt.loadNpmTasks
# Configurable paths
coreConfig =
pkg: grunt.file.readJSON("package.json")
app: "app"
dist: "dist"
banner: do ->
banner = "/*!\n"
banner += " * (c) <%= core.pkg.author %>.\n *\n"
banner += " * <%= core.pkg.name %> - v<%= core.pkg.version %> (<%= grunt.template.today('mm-dd-yyyy') %>)\n"
banner += " * <%= core.pkg.homepage %>\n"
banner += " * <%= core.pkg.licenses.type %> - <%= core.pkg.licenses.url %>\n"
banner += " */"
banner
# Project configurations
grunt.initConfig
core: coreConfig
coffeelint:
options:
indentation: 2
no_stand_alone_at:
level: "error"
no_empty_param_list:
level: "error"
max_line_length:
level: "ignore"
gruntfile:
files:
src: ["Gruntfile.coffee"]
test:
files:
src: ["<%= core.app %>/assets/coffee/main.coffee"]
connect:
options:
port: 9000
# change this to "0.0.0.0" to access the server from outside
hostname: "0.0.0.0"
livereload:
options:
middleware: (connect) ->
[lrSnippet, mountFolder(connect, ".tmp"), mountFolder(connect, coreConfig.app)]
test:
options:
middleware: (connect) ->
[mountFolder(connect, ".tmp"), mountFolder(connect, "test")]
dist:
options:
middleware: (connect) ->
[mountFolder(connect, coreConfig.dist)]
watch:
grunt:
files: ["<%= coffeelint.gruntfile.files.src %>"]
tasks: ["coffeelint"]
coffee:
files: ["<%= coffeelint.test.files.src %>"]
tasks: ["coffeelint"]
less:
files: ["<%= core.app %>/assets/less/main.less"]
tasks: ["less:server", "autoprefixer:server"]
livereload:
options:
livereload: LIVERELOAD_PORT
files: ["<%= core.app %>/*.html", "{.tmp,<%= core.app %>}/assets/css/{,*/}*.css", "{.tmp,<%= core.app %>}/assets/js/{,*/}*.js", "<%= core.app %>/assets/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}"]
coffee:
server:
options:
sourceMap: true
files:
".tmp/assets/js/main.js": ["<%= core.app %>/assets/coffee/main.coffee"]
dist:
files:
"<%= core.dist %>/assets/js/main.js": ["<%= core.app %>/assets/coffee/main.coffee"]
less:
server:
options:
paths: ["<%= core.app %>"]
# dumpLineNumbers: "all"
files:
".tmp/assets/css/main.css": ["<%= core.app %>/assets/less/main.less"]
dist:
options:
paths: ["<%= core.app %>"]
files:
"<%= core.dist %>/assets/css/main.css": ["<%= core.app %>/assets/less/main.less"]
autoprefixer:
server:
files:
".tmp/assets/css/main.css": [".tmp/assets/css/main.css"]
dist:
files:
"<%= core.dist %>/assets/css/main.css": ["<%= core.dist %>/assets/css/main.css"]
htmlmin:
dist:
options:
removeComments: true
removeCommentsFromCDATA: true
removeCDATASectionsFromCDATA: true
collapseWhitespace: true
conservativeCollapse: true
collapseBooleanAttributes: true
removeAttributeQuotes: false
removeRedundantAttributes: true
useShortDoctype: false
removeEmptyAttributes: true
removeOptionalTags: true
removeEmptyElements: false
lint: false
keepClosingSlash: true
caseSensitive: true
minifyJS: true
minifyCSS: true
files: [
expand: true
cwd: "<%= core.app %>"
src: "**/*.html"
dest: "<%= core.dist %>/"
]
cssmin:
dist:
options:
banner: "<%= core.banner %>"
report: "gzip"
files:
"<%= core.dist %>/assets/css/main.css": ["<%= core.dist %>/assets/css/main.css"]
uglify:
dist:
options:
banner: "<%= core.banner %>"
report: "gzip"
files:
"<%= core.dist %>/assets/js/main.js": ["<%= core.dist %>/assets/js/main.js"]
copy:
sync:
files: [
expand: true
dot: true
cwd: "<%= core.dist %>/"
src: ["**"]
dest: "/Users/sparanoid/Workspace/Sites/sparanoid.com/lab/<%= core.pkg.name %>/"
]
clean:
dist:
files: [
dot: true
src: [".tmp", "<%= core.dist %>/*"]
]
sync:
options:
force: true
files: [
src: "/Users/sparanoid/Workspace/Sites/sparanoid.com/lab/<%= core.pkg.name %>/"
]
concurrent:
options:
logConcurrentOutput: true
server:
tasks: ["less:server", "coffee:server"]
dist:
tasks: ["htmlmin", "cssmin", "uglify"]
grunt.registerTask "serve", ["connect:livereload", "concurrent:server", "autoprefixer:server", "watch"]
grunt.registerTask "test", ["coffeelint"]
grunt.registerTask "build", ["clean:dist", "test", "less:dist", "autoprefixer:dist", "coffee:dist", "concurrent:dist"]
grunt.registerTask "sync", ["build", "clean:sync", "copy:sync"]
grunt.registerTask "default", ["build"]