-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.coffee
160 lines (144 loc) · 3.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
module.exports = (grunt) ->
# Show elapsed time at the end.
require('time-grunt')(grunt)
# Load all grunt tasks.
require('load-grunt-config')(grunt)
srcCoffeeDir = 'src/coffee/'
destJsDir = 'contents/js/'
compressJsDir = 'contents/compress/'
srcLessDir = 'src/less/'
destCssDir = 'contents/css/'
# Specify relative path from "src/coffee/".
bare_list = [
'common.coffee'
]
reTrimCwd = new RegExp '^src/coffee/'
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
meta:
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> -' +
' <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.repository.url %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %>' +
' Yonchu; Licensed MIT\n' +
' */'
coffee:
compile:
options:
sourceMap: false
files: [
expand: true,
cwd: srcCoffeeDir,
src: ['**/*.coffee'],
dest: destJsDir,
ext: '.js'
filter: (path) ->
noCwdPath = path.replace reTrimCwd, ''
return not (noCwdPath in bare_list)
]
compileBare:
options:
bare: true,
sourceMap: false
files: [
expand: true,
cwd: srcCoffeeDir,
src: bare_list,
dest: destJsDir,
ext: '.js'
]
less:
development:
files: [
expand: true,
cwd: srcLessDir,
src: ['**/*.less'],
dest: destCssDir,
ext: '.css'
]
production:
options:
yuicompress: true
files: [
expand: true,
cwd: srcLessDir,
src: ['**/*.less'],
dest: destCssDir,
ext: '.css'
]
uglify:
compress_target:
options:
sourceMap: (fileName) ->
fileName.replace /\.js$/, '.js.map'
banner: '<%= meta.banner %>'
files: [
expand: true,
cwd: destJsDir,
src: ['**/*.js'],
dest: compressJsDir,
filter: (path) ->
return not (path.match 'js/lib/vendor/')
]
regarde:
coffee:
files: ["#{srcCoffeeDir}**/*.coffee"],
tasks: ['coffee']
less:
files: ["#{srcLessDir}**/*.less"],
tasks: ['less:development']
coffeelint:
options:
configFile: 'coffeelint.json'
all:
files:
src: ["#{srcCoffeeDir}**/*.coffee"]
jsonlint:
all:
files:
src: [
'*.json', '.bowerrc', '.jshintrc',
'contents/manifest.json'
]
jshint:
options:
jshintrc: '.jshintrc'
all:
src: [
"#{destJsDir}**/*.js"
],
filter: (path) ->
return false if path.match '/lib/'
return false if path is 'contents/js/popup-tmpl.js'
return true
clean:
js:
src: [
"#{destJsDir}**/*.js",
],
filter: (path) ->
return not (path.match '/lib/')
jsmap:
src: [
"#{destJsDir}**/*.map"
],
filter: (path) ->
return not (path.match '/lib/vendor/')
compress:
src: [
"#{compressJsDir}**/*.js",
"#{compressJsDir}**/*.map",
"#{compressJsDir}lib"
]
css:
src: [
"#{destCssDir}**/*.css"
]
# Rename
# grunt.renameTask('regarde', 'watch');
# Register custom tasks.
grunt.registerTask 'watch', ['regarde']
grunt.registerTask 'build', ['coffeelint', 'jsonlint', 'coffee', 'less:development']
grunt.registerTask 'release', ['coffeelint', 'jsonlint', 'coffee', 'uglify', 'less:production']
# Register default task.
grunt.registerTask 'default', ['build']