-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
260 lines (229 loc) · 5.84 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*jshint camelcase:false */
// Generated on 2013-03-20 using generator-closure 0.1.1
var compiler = require('superstartup-closure-compiler'),
path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(path.resolve(dir));
};
module.exports = function (grunt) {
//
//
// Configure tasks
//
//
//
// The folder that contains all the externs files.
var EXTERNS_PATH = 'build/externs/';
// define the main namespace of your app
var ENTRY_POINT = 'ssd.helpers';
// The path to the closure library
var CLOSURE_LIBRARY = 'closure-library';
// the compiled file
var DEST_COMPILED = 'temp/helpers.compiled.js';
// define the path to the app
var APP_PATH = 'lib';
// The location of the source map
var SOURCE_MAP = 'app/jsc/sourcemap.js.map';
// This sting will wrap your code marked as %output%
// Take care to edit the sourcemap path
var OUTPUT_WRAPPER = '(function(){%output%}).call(this);\n' +
'//@sourceMappingURL=/jsc/sourcemap.js.map\n';
//
//
// Start Gruntconfig
//
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
release: {
options: {
bump: true, //default: true
file: 'package.json', //default: package.json
add: true, //default: true
commit: true, //default: true
tag: true, //default: true
push: true, //default: true
pushTags: true, //default: true
npm: true, //default: true
tagName: 'v<%= version %>', //default: '<%= version %>'
commitMessage: 'releasing v<%= version %>', //default: 'release <%= version %>'
tagMessage: 'v<%= version %>' //default: 'Version <%= version %>'
}
},
watch: {
livereload: {
files: [
APP_PATH + '/*.js'
],
tasks: ['livereload']
},
test: {
files: [
APP_PATH + '/*.js',
'test/**/*.js'
],
tasks: ['livereload']
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost',
keepalive: false
},
livereload: {
options: {
middleware: function (connect) {
return [ lrSnippet, mountFolder(connect, 'lib')];
}
}
},
test: {
options: {
port: 4242,
base: './',
keepalive: false
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
},
test: {
path: 'http://localhost:<%= connect.test.options.port %>/test/'
}
},
mocha: {
all: {
options: {
run: true,
ignoreLeaks: false,
urls: [
'http://localhost:<%= connect.test.options.port %>/test/index.html',
'http://localhost:<%= connect.test.options.port %>/test/index.html?compiled=true',
'http://localhost:<%= connect.test.options.port %>/test/index.html?unit=true'
]
}
}
},
//
//
//
// Closure Tools Tasks
//
// Dependency & Compiling
//
//
//
closureDepsWriter: {
options: {
closureLibraryPath: CLOSURE_LIBRARY
},
app: {
options: {
root_with_prefix: ['"' + APP_PATH + ' ../../../lib/"']
},
dest: '' + APP_PATH + '/deps.js'
},
bddTest: {
options: {
root_with_prefix: ['"test ../../../../../test"']
},
dest: 'test/bdd/deps-test-bdd.js'
},
unitTest: {
options: {
root_with_prefix: ['"test ../../../../../test"']
},
dest: 'test/unit/deps-test-tdd.js'
}
},
closureBuilder: {
options: {
closureLibraryPath: CLOSURE_LIBRARY,
inputs: [APP_PATH + '/main.js'],
compile: true,
compilerFile: compiler.getPathSS(),
compilerOpts: {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
externs: [EXTERNS_PATH + '*.js'],
define: [
'\'goog.DEBUG=false\''
],
warning_level: 'verbose',
jscomp_off: ['checkTypes', 'fileoverviewTags'],
summary_detail_level: 3,
only_closure_dependencies: null,
closure_entry_point: ENTRY_POINT,
create_source_map: SOURCE_MAP,
source_map_format: 'V3',
output_wrapper: OUTPUT_WRAPPER
}
},
app: {
src: [APP_PATH, CLOSURE_LIBRARY],
dest: 'temp/compiled.js'
},
debug: {
options: {
compilerFile: compiler.getPath()
},
src: [APP_PATH, CLOSURE_LIBRARY],
dest: 'temp/compiled.debug.js'
}
},
// clean, uglify and concat aid in building
clean: {
dist: ['temp'],
server: 'temp'
}
});
//
//
// initConfig END
//
// Register tasks
//
//
grunt.renameTask('regarde', 'watch');
grunt.registerTask('server', function (target) {
if (target === 'test') {
return grunt.task.run([
'clean:server',
'livereload-start',
'connect:test',
'open:test',
'watch:test'
]);
}
grunt.task.run([
'clean:server',
'livereload-start',
'connect:livereload',
'open:server',
'watch:livereload'
]);
});
grunt.registerTask('test', [
'clean:server',
'connect:test',
'mocha'
]);
grunt.registerTask('build', [
'clean:dist',
'uglify:vendor',
'closureBuilder:app',
'concat:production'
]);
grunt.registerTask('deps', [
'closureDepsWriter:app',
'closureDepsWriter:bddTest',
'closureDepsWriter:unitTest'
]);
grunt.registerTask('default', [
'deps'
]);
};