-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGruntfile.coffee
140 lines (109 loc) · 2.86 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
module.exports = (grunt) ->
# Configuration
# -------------
pkg = grunt.file.readJSON 'package.json'
grunt.initConfig {
pkg
clean:
build: 'bin/*'
dist: 'dist/*'
distAfter: 'dist/temp/'
docs: 'docs/*'
compress:
dist:
files: [
expand: true
cwd: 'dist/temp/'
src: '**/*'
]
options:
archive: 'dist/Template.zip'
level: 9
pretty: yes
copy:
build:
expand: yes
cwd: 'src/'
src: ['**', '!lib/*']
dest: 'bin/'
dist:
expand: yes
cwd: 'bin/'
src: ['**', '!lib/*', '!vendor/**/*.js', 'vendor/**/*.min.js']
dest: 'dist/temp/'
coffee:
build:
expand: yes
cwd: 'src/lib/'
src: '*.coffee'
dest: 'bin/lib/'
ext: '.js'
docco:
dist:
src: 'src/lib/**/*.coffee'
options:
output: 'docs/'
'json-minify':
dist:
files: 'dist/temp/**/*.json'
'locale-prepare':
dist:
files: 'dist/temp/_locales/**/*.json'
uglify:
distLib:
files: [
expand: yes
cwd: 'bin/lib/'
src: '*.js'
dest: 'dist/temp/lib/'
]
options:
banner: """
/*! Template v<%= pkg.version %> | (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | <%= pkg.licenses[0].url %> */
"""
distVendor:
files: [
expand: yes
cwd: 'bin/vendor/'
src: ['**/*.js', '!**/*.min.js']
dest: 'dist/temp/vendor/'
]
options:
preserveComments: 'some'
}
# Tasks
# -----
for dependency of pkg.devDependencies when ~dependency.indexOf 'grunt-'
grunt.loadNpmTasks dependency
grunt.registerTask 'build', [
'clean:build'
'copy:build'
'coffee'
]
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}\"..."
messages = grunt.file.readJSON file
for name, message of messages
delete message.description
if message.placeholders
delete placeholder.example for key, placeholder of message.placeholders
grunt.file.write file, JSON.stringify messages
grunt.log.ok()