-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
188 lines (149 loc) · 5.16 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
"use strict";
var projects = [
"client",
"server"
];
var repo = "UICatalogManager";
module.exports = function(grunt) {
// Time how long tasks take. Can help when optimizing build times
require("time-grunt")(grunt);
require("mocha-jenkins-reporter");
// Load grunt tasks automatically, when needed
require("jit-grunt")(grunt, {
injector: "grunt-asset-injector",
ngtemplates: "grunt-angular-templates",
protractor: "grunt-protractor-runner",
express: "grunt-express-server",
ngAnnotate: "grunt-ng-annotate"
});
grunt.loadNpmTasks("grunt-string-replace");
grunt.loadNpmTasks("grunt-mocha-istanbul");
// Define the configuration for all the tasks
grunt.initConfig({
// vars
env: {
dev: {
NODE_ENV: "development"
},
prod: {
NODE_ENV: "production"
},
test: {
NODE_ENV: "test"
},
jenkins: {
NODE_ENV: "jenkins"
},
client: "sample/client",
server: "sample/server"
},
//Access information from package.json
pkg: grunt.file.readJSON("package.json"),
// convert svg images to sprite
svg_sprite: require("./grunt-conf/svg-sprite.js"),
// Make sure code styles are up to par and there are no obvious mistakes
eslint: require("./grunt-conf/eslint.js"),
// Empties folders to start fresh
clean: require("./grunt-conf/clean.js"),
// Convert less to css
less: require("./grunt-conf/less.js"),
// Minify css
cssmin: require("./grunt-conf/cssmin.js"),
// Minify js
uglify: require("./grunt-conf/uglify.js"),
// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngAnnotate: require("./grunt-conf/ngannotate.js"),
// Copies remaining files to places other tasks can use
copy: require("./grunt-conf/copy.js"),
// wrap node modules for browser
browserify: require("./grunt-conf/browserify.js"),
// JS doc files
jsdoc: require("./grunt-conf/jsdoc.js"),
"string-replace": require("./grunt-conf/string-replace.js"),
// externalize source maps from bundle.js
exorcise: {
bundle: {
files: {
"dev/assets/bundle.js.map": ["dev/assets/bundle.js"]
}
}
},
// Test settings
karma: require("./grunt-conf/karma.js"),
// Watch files
watch: require("./grunt-conf/watch.js"),
/*** SERVER *******************************************************************************/
// Server settings
express: require("./grunt-conf/express.js"),
// Server tests
mocha_istanbul: require("./grunt-conf/mocha.js"),
// e2e tests
protractor: require("./grunt-conf/protractor.js"),
// Debugging with node inspector
"node-inspector": {
custom: {
options: {
"web-host": "localhost"
}
}
}
});
grunt.registerTask("svg-sprite", ["clean", "svg_sprite", "string-replace:UICatalog"]);
grunt.registerTask("express-keepalive", "Keep grunt running", function() {
this.async();
});
grunt.registerTask("serve", function(target) {
var tasks = {
debug: [
"env:dev",
"express:dev",
"node-inspector"
],
dev: [
"build",
"env:dev",
"express:dev",
"watch"
]
};
return grunt.task.run(tasks[target || "dev"]);
});
grunt.registerTask("test", function(target) {
var tasks = {
server: ["mocha_istanbul"],
client: ["browserify", "karma"],
e2e: ["express:dev", "protractor"],
dflt: ["env:test", "test:server", "test:client"]
};
return grunt.task.run(tasks[target || "dflt"]);
});
grunt.registerTask("build", function(target) {
target = target || "dev";
var tasks = [
"eslint",
"clean:" + target,
"less",
//"copy:html",
"copy:client",
"copy:server",
"copy:dev",
"browserify",
"ngAnnotate"
];
if (target === "dev") {
//tasks.push("exorcise");
} else {
tasks.push("copy:dist");
tasks.push("cssmin");
tasks.push("uglify");
}
return grunt.task.run(tasks);
});
// just run (app must be already built)
grunt.registerTask("start", ["env:dev", "express:dev", "watch"]);
//grunt.registerTask("dist", ["env:dev", "build:dist", "test:server"]);
grunt.registerTask("dist", ["env:dev", "build:dist", "test:server", "jsdoc:dist"]);
grunt.registerTask("dev", ["build:dev", "test"]);
grunt.registerTask("default", ["build:dev", "test"]);
};