This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
299 lines (268 loc) · 6.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
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
295
296
297
298
299
module.exports = (grunt) ->
grunt.initConfig
# Read the main package
pkg: grunt.file.readJSON('package.json')
# Set the directory defaults
dir:
app: 'app'
js: 'app/js'
coffee: 'app/js/coffee'
css: 'app/css'
sass: 'app/css/scss'
img: 'app/img'
# Distribution
dist:
root: 'dist'
js: 'dist/js'
css: 'dist/css'
img: 'dist/img'
# Concatenate files
# https://github.com/gruntjs/grunt-contrib-concat
concat:
dist:
src: [
'<%= dir.js %>/*.js'
]
dest: '<%= dist.js %>/scripts.js'
vendor:
src: [
'<%= dir.js %>/vendors/*.js'
]
dest: '<%= dir.js %>/plugins.js'
# Validate files with JSHint.
# https://github.com/gruntjs/grunt-contrib-jshint
jshint:
all: [
'<%= dir.js %>/*.js'
'!<%= dir.js %>/plugins.js'
]
# Uglify
# Minify files with UglifyJS
# https://github.com/gruntjs/grunt-contrib-uglify
uglify:
build:
src: [
'<%= dist.js %>/plugins.js'
'<%= dist.js %>/scripts.js'
]
dest: '<%= dist.js %>/scripts.min.js'
# Image Min
# Minify PNG and JPEG images
# https://github.com/gruntjs/grunt-contrib-imagemin
imagemin:
compress:
options:
optimizationLevel: 3
files: [
expand: true
cwd: '<%= dir.img %>/'
src: '{,*/}*.{png,jpg,jpeg}'
dest: '<%= dist.img %>'
]
# Minify SVG
# https://github.com/sindresorhus/grunt-svgmin
svgmin:
options:
plugins: [
removeViewBox: false
removeUselessStrokeAndFill: false
]
dist:
files: [
expand: true
cwd: '<%= dir.img %>/'
src: ['**/*.svg']
dest: '<%= dist.img %>/'
]
# Compile Sass SCSS to CSS
# https://github.com/gruntjs/grunt-contrib-sass
sass:
dev:
options:
style: 'expanded'
require: [
'bourbon'
'neat'
]
sourcemap: true
files: [
'<%= dir.css %>/styles.css' : '<%= dir.sass %>/main.scss'
]
dist:
options:
style: 'compressed'
require: [
'bourbon'
'neat'
]
files: [
'<%= dist.css %>/styles.css' : '<%= dir.sass %>/main.scss'
]
# Compile CoffeeScript files to JavaScript.
# https://github.com/gruntjs/grunt-contrib-coffee
coffee:
compile:
files: [
'<%= dir.js %>/scripts.js' : '<%= dir.coffee %>/scripts.coffee'
]
# CoffeeLint
# https://github.com/vojtajina/grunt-coffeelint
coffeelint:
app: [
'<%= dir.coffee %>/*.coffee'
'gruntfile.coffee'
]
options:
'no_trailing_whitespace':
'level': 'error'
# Notify
# Automatic Notifications when Grunt tasks fail.
# https://github.com/dylang/grunt-notify
notify_hooks:
options:
enabled: true
max_jshint_notifications: 5
# Copy files and folders
# https://github.com/gruntjs/grunt-contrib-copy
copy:
main:
files: [
{
expand: true
src: '.htaccess'
dest: '<%= dist.root %>'
},{
expand: true
src: 'robots.txt'
dest: '<%= dist.root %>'
}
]
# Autoprefixer
# Parse CSS and add vendor-prefixed CSS properties
# using the Can I Use database. Based on Autoprefixer
autoprefixer:
single_file:
options:
browsers: ['last 15 version', 'ie 8', 'ie 9']
src: '<%= dir.css %>/styles.css'
dest: '<%= dir.css %>/styles.css'
# Clear files and folders
# https://github.com/gruntjs/grunt-contrib-clean
clean:
root: [
'<%= dist.root %>'
]
scripts: [
'<%= dist.js %>/scripts.js'
]
images: [
'<%= dir.img %>/sprt.png'
]
# Connect is a middleware layer for Node.js
# https://github.com/senchalabs/connect
connect:
options:
port: 9000
livereload: 35729
hostname: 'localhost'
livereload:
options:
open: true
base: './<%= dir.app %>'
# Run grunt tasks concurrently
# https://github.com/sindresorhus/grunt-concurrent
concurrent:
server:
'sass'
# Grunt task for converting a set of images into a
# sprite and corresponding CSS variables
# https://github.com/Ensighten/grunt-spritesmith
sprite:
all:
src: '<%= dir.img %>/*.png'
destImg: '<%= dir.img %>/sprt.png'
destCSS: '<%= dir.sass %>/modules/_sprite.scss'
cssFormat: 'scss'
processhtml:
prod:
files: [
'<%= dist.root %>/index.html' : '<%= dir.app %>/index.html'
]
# Run tasks whenever watched files change.
# https://github.com/gruntjs/grunt-contrib-watch
watch:
options:
livereload: true
images:
files: [
'<%= dir.img %>/*.png'
]
tasks: [
'clean:image',
'sprite'
]
scripts:
files: [
'<%= dir.js %>/**/*.js'
'<%= dir.coffee %>/**/*.coffee'
'<%= uglify.build.src %>'
]
tasks: [
'concat:vendor'
'coffee'
'coffeelint'
'jshint'
]
options:
spawn: false
sass:
files: [
'<%= dir.sass %>/**/*.scss'
]
tasks: [
'sass:dev'
'autoprefixer'
]
options:
spawn: false
scaffold:
files: [
'**/*.{html,php}',
'<%= dir.img %>/**/*.{png,jpg,jpeg,gif,svg}'
]
# Load Tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
# Run Notify
grunt.task.run('notify_hooks')
# Run with 'grunt'
grunt.registerTask 'default', [
'sass:dev'
'coffee'
'coffeelint'
'concat:vendor'
'jshint'
]
# Run with 'grunt production'
grunt.registerTask 'production', [
'clean:root'
'coffee'
'coffeelint'
'sass:dist'
'autoprefixer'
'concat'
'uglify'
'jshint'
'copy'
'svgmin'
'imagemin'
'processhtml'
'clean:scripts'
]
grunt.registerTask 'serve', (target) ->
if target == 'dist'
return grunt.task.run(['build', 'connect:dist:keepalive'])
grunt.task.run(
'autoprefixer'
'connect:livereload'
'watch'
)