-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.coffee
136 lines (115 loc) · 2.77 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
module.exports = (grunt) ->
##
# Config
#
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
'*/\n'
less:
app:
options:
compress: false
paths: [
'css'
'vendors'
]
files:
'css/app.css': 'css/app.less'
cssmin:
app:
files:
'css/app.css': ['css/app.css']
coffee:
app:
files:
'tmp/app.js': 'js/app.coffee'
concat:
options:
banner: '<%= banner %>'
js:
src: [
'tmp/icons.js'
'vendors/angular/angular.js'
'tmp/app.js'
]
dest: 'js/app.js'
uglify:
options:
mangle: false
app:
files:
'js/app.js': ['js/app.js']
watch:
app:
files: [
'css/app.less'
'js/app.coffee'
]
tasks: ['build']
clean:
tmp:
files: [{
dot: true
src: [
'tmp'
]
}]
##
# Load plugins
#
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-uglify'
##
# Custom tasks
#
grunt.registerTask 'iconsData', () ->
varsPath = __dirname + '/vendors/font-awesome/less/variables.less'
content = grunt.file.read varsPath, encoding: 'utf8'
varsLines = content.split "\n"
data = grunt.file.readJSON 'data.json'
faNames = []
# add/update
for k, v of varsLines
line = v.split ':'
varName = line[0].replace '@', ''
if varName.indexOf('fa-var') is -1
continue
faName = varName.replace 'fa-var-', 'fa-'
if !faName? and faName.length is 0
continue
faNames.push faName
if !data[faName]?
data[faName] =
name: faName
keywords: []
# remove
for k, v of data
if faNames.indexOf(k) is -1
delete data[k]
# write JSON
write = JSON.stringify data, null, 2
grunt.file.write 'data.json', write
# write JS
grunt.file.write 'tmp/icons.js', 'var icons = ' + write + ';'
##
# Tasks
#
grunt.registerTask 'build', [
'clean:tmp'
'iconsData'
'less:app'
'coffee:app'
'concat:js'
'cssmin:app'
'uglify:app'
]
grunt.registerTask 'default', ['build']