-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.js
90 lines (77 loc) · 2.34 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
/*jshint -W106 */
/*jshint node:true, maxstatements: false, maxlen: false */
module.exports = function(grunt) {
"use strict";
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON("package.json"),
banner: "/*!\n" +
"* <%= pkg.title || pkg.name %>\n" +
"* <%= pkg.description %>\n" +
"* Copyright (c) 2014<%= (function(thisYear) { return thisYear !== '2014' ? '-' + thisYear : ''; })(grunt.template.today('yyyy')) %> <%= pkg.author.name %>\n" +
"* Licensed <%= pkg.license %>\n" +
"* <%= pkg.homepage %>\n" +
"* v<%= pkg.version %>\n" +
"*/\n\n",
srcFile: "index.js",
// Task configuration.
jshint: {
options: {
jshintrc: true
},
gruntfile: ["Gruntfile.js"],
src: ["<%= srcFile %>"]
},
uglify: {
options: {
banner: "<%= banner %>",
report: "min"
},
js: {
options: {
preserveComments: "all",
beautify: {
beautify: true,
// `indent_level` requires jshint -W106
indent_level: 2
},
mangle: false,
compress: false
},
files: [{
src: "<%= srcFile %>",
dest: "dist/<%= pkg.name %>.js"
}]
},
min: {
options: {
preserveComments: function(node, comment) {
return comment &&
comment.type === "comment2" &&
/^(!|\*!)\r?\n/.test(comment.value);
},
sourceMap: true,
sourceMapName: function(dest) {
return dest.replace(".min.js", ".min.map");
},
// Bundles the contents of "`src`" into the "`dest`.map" source map file. This way,
// consumers only need to host the "*.min.js" and "*.min.map" files rather than
// needing to host all three files: "*.js", "*.min.js", and "*.min.map".
sourceMapIncludeSources: true
},
files: [{
src: "<%= srcFile %>",
dest: "dist/<%= pkg.name %>.min.js"
}]
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
// Default task.
grunt.registerTask("default", ["jshint", "uglify"]);
// Travis CI task.
grunt.registerTask("travis", ["jshint"]);
};