-
Notifications
You must be signed in to change notification settings - Fork 14
/
Gruntfile.coffee
184 lines (147 loc) · 3.84 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
# Module dependencies
# -------------------
int17 = require 'int17'
module.exports = (grunt) ->
# Configuration
# -------------
pkg = grunt.file.readJSON 'package.json'
grunt.initConfig {
pkg
clean:
build: [ 'bin/img/**', 'bin/vendor/**', 'bin/*.html' ]
buildAll: 'bin/*'
buildJSON: [ 'bin/_locales/**', 'bin/*.json' ]
buildStyles: 'bin/less/*'
buildScripts: 'bin/coffee/*'
dist: 'dist/*'
distAfter: 'dist/temp/'
docs: 'docs/*'
compress:
dist:
files: [
expand: true
cwd: 'dist/temp/'
src: '**/*'
]
options:
archive: 'dist/Injector.zip'
level: 9
pretty: yes
copy:
build:
expand: yes
cwd: 'src/'
src: [ 'img/**', 'vendor/**', '*.html' ]
dest: 'bin/'
buildStyles:
expand: yes
cwd: 'src/'
src: [ 'css/**' ]
dest: 'bin/'
buildScripts:
expand: yes
cwd: 'src/'
src: [ 'js/**' ]
dest: 'bin/'
dist:
expand: yes
cwd: 'bin/'
src: [ '**', '!js/*' ]
dest: 'dist/temp/'
coffee:
build:
expand: yes
cwd: 'src/coffee/'
src: '*.coffee'
dest: 'bin/js/'
ext: '.js'
cson:
buildJSON:
expand: yes
cwd: 'src/'
src: '**/*.cson'
dest: 'bin/'
ext: '.json'
docco:
dist:
src: 'src/coffee/*'
options:
output: 'docs/'
'json-minify':
dist:
files: 'dist/temp/**/*.json'
less:
build:
files: [
expand: yes
cwd: 'src/less/'
src: '*.less'
dest: 'bin/css/'
ext: '.css'
]
options:
compress: yes
'locale-prepare':
dist:
files: 'dist/temp/_locales/**/*.json'
uglify:
dist:
files: [
expand: yes
cwd: 'bin/js/'
src: '*.js'
dest: 'dist/temp/js/'
]
options:
banner: """
/*! Injector v<%= pkg.version %> | (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | <%= pkg.licenses[0].type %> License */
"""
watch:
build:
files: [ 'src/img/**', 'src/vendor/**', 'src/*.html' ]
tasks: [ 'clean:build', 'copy:build' ]
buildJSON:
files: [ 'src/_locales/**', 'src/*.cson' ]
tasks: [ 'clean:buildJSON', 'cson' ]
buildStyles:
files: [ 'src/css/**', 'src/less/**' ]
tasks: [ 'clean:buildStyles', 'copy:buildStyles', 'less' ]
buildScripts:
files: [ 'src/js/**', 'src/coffee/**' ]
tasks: [ 'clean:buildScripts', 'copy:buildScripts', 'coffee' ]
}
# Tasks
# -----
for dependency of pkg.devDependencies when ~dependency.indexOf 'grunt-'
grunt.loadNpmTasks dependency
grunt.registerTask 'build', [
'clean:buildAll'
'copy:build'
'copy:buildScripts'
'copy:buildStyles'
'coffee'
'cson'
'less'
]
grunt.registerTask 'dist', [
'clean:dist'
'copy:dist'
'locale-prepare'
'json-minify'
'uglify'
'compress'
'clean:distAfter'
]
grunt.registerTask 'docs', [
'clean:docs'
'docco'
]
grunt.registerTask 'default', [ 'build' ]
# Remove all of the long message descriptions and placeholder examples as they're not required by
# users and Chrome Web Store has a size limit for locale files.
grunt.registerMultiTask 'locale-prepare', 'Locale JSON preparation task', ->
files = grunt.file.expand @data.files
files.forEach (file) ->
grunt.log.write "Preparing \"#{file}\"..."
grunt.file.write file, JSON.stringify int17.optimize grunt.file.readJSON file
grunt.log.ok()