-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGruntfile.js
executable file
·194 lines (185 loc) · 6.97 KB
/
Gruntfile.js
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
/*global module:false*/
module.exports = function(grunt) {
'use strict';
// node libs.
var path = require('path');
// internal libs.
var profileUtil = require('./lib/utils/profile');
var log = require('./lib/utils/log');
var file = require('./lib/utils/file');
var mimes = require('./lib/common/mimes');
var pkg = file.readJSON('package.json');
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: pkg,
mimes: mimes,
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + '* Copyright (c) <%= grunt.template.today("yyyy") %> frontend@ablesky.com;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
clean: {
options: {
// overrides this task from blocking deletion of folders outside current working dir (CWD)
force: true
},
image: {
src: ['<%= mimes.image.dest_path %>']
},
css: {
src: ['<%= mimes.css.dest_path %>']
},
js: {
src: ['<%= mimes.js.dest_path %>']
},
jsp: {
src: ['<%= mimes.tmpl.dest_path %>']
}
},
jshint: {
ablejs: {
options: {
// http://www.jshint.com/docs/options/
jshintrc: '.jshintrc'
},
src: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
},
develop: {
options: {
// http://www.jshint.com/docs/options/
jshintrc: path.join(mimes.js.src_path, '.jshintrc')
},
base: 'dist/jshint/',
src: ['<%= jshint.develop.base %>**/*.js']
}
},
copy: {
profile: {
// Src matches are relative to this path.
cwd: '<%= mimes.js.src_path %>',
// match all match files in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['profile.json'],
// Destination path prefix.
dest: '<%= mimes.js.src_path %>',
filter: 'isFile'
},
css: {
// Src matches are relative to this path.
cwd: '<%= mimes.css.src_path %>',
// match all files ending with .css in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['api/ablesky.api.login.css'],
// Destination path prefix.
dest: '<%= mimes.css.dest_path %>',
filter: 'isFile'
},
js: {
// Src matches are relative to this path.
cwd: '<%= mimes.js.src_path %>',
// match all match files in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['api/ablesky.api.login.js', 'tinymce/**'],
// Destination path prefix.
dest: '<%= mimes.js.dest_path %>',
filter: 'isFile'
}
},
concat: {
options: {
banner: '' // do not add <%= banner %> in concat task.
},
css: {
// Src matches are relative to this path.
cwd: '<%= mimes.css.src_path %>',
files: profileUtil.getConcats('css')
},
js: {
// Src matches are relative to this path.
cwd: '<%= mimes.js.src_path %>',
files: profileUtil.getConcats('js')
}
},
optiimg: {
files: {
// Src matches are relative to this path.
cwd: '<%= mimes.image.src_path %>',
// match all files in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['**/*', '!**/*.psd'],
// Destination path prefix.
dest: '<%= mimes.image.dest_path %>',
filter: 'isFile'
}
},
opticss: {
options: {
banner: '<%= banner %>'
},
files: {
// Src matches are relative to this path.
cwd: '<%= mimes.css.src_path %>',
// match all files ending with .css in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['**/*.css', '!api/ablesky.api.login.css'],
// Destination path prefix.
dest: '<%= mimes.css.dest_path %>'
}
},
optijs: {
options: {
banner: '<%= banner %>'
},
files: {
// Src matches are relative to this path.
cwd: '<%= mimes.js.src_path %>',
// match all files ending with .js in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['**/*.js', '**/*.swf', '!tinymce/**/*.js'],
// Destination path prefix.
dest: '<%= mimes.js.dest_path %>'
}
},
optijsp: {
options: {
jsBasePath: '<%= mimes.js.src_path %>'
},
files: {
// Src matches are relative to this path.
cwd: '<%= mimes.tmpl.src_path %>',
// match all files ending with .js in the ${cwd}/ subdirectory and all of its subdirectories.
src: ['**/*.jsp'],
// Destination path prefix.
dest: '<%= mimes.tmpl.dest_path %>'
}
},
replace: {
jsp: {
// Src matches are relative to this path.
cwd: '<%= mimes.tmpl.dest_path %>',
src: ['**/*.jsp'],
// toreplace can be regexp | str
toreplace: /<%=staticsServer%>images/g,
newstring: '<%=imgPath%>'
}
},
chrono: {
options: {
start: new Date()
}
},
patch: {
options: {
// the flag can turn on/off the jshint task at patch task.
jshint: false,
// the path to run jshint task
jshintpath: '<%= jshint.develop.base %>',
root: {
img: mimes.image.src_dir,
css: mimes.css.src_dir,
js: mimes.js.src_dir,
jsp: mimes.tmpl.src_dir
}
}
}
});
// load custom tasks.
grunt.loadTasks('lib/tasks');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task.
grunt.registerTask('build', ['clean', 'concat', 'copy', 'optiimg', 'opticss', 'optijs', 'optijsp', 'chrono']);
grunt.registerTask('default', ['build']);
};