-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
221 lines (206 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
/*
* Copyright 2013, Nexedi SA
*
* This program is free software: you can Use, Study, Modify and Redistribute
* it under the terms of the GNU General Public License version 3, or (at your
* option) any later version, as published by the Free Software Foundation.
*
* You can also Link and Combine this program with other software covered by
* the terms of any of the Free Software licenses or any of the Open Source
* Initiative approved licenses and Convey the resulting work. Corresponding
* source of such a combination shall include the source code for all other
* software used.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*global require */
module.exports = function (grunt) {
"use strict";
var LIVERELOAD_PORT, lrSnippet, livereloadMiddleware;
// This is the default port that livereload listens on;
// change it if you configure livereload to use another port.
LIVERELOAD_PORT = 35729;
// lrSnippet is just a function.
// It's a piece of Connect middleware that injects
// a script into the static served html.
lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
// All the middleware necessary to serve static files.
livereloadMiddleware = function (connect, options) {
return [
// Inject a livereloading script into static files.
lrSnippet,
// Serve static files.
connect.static(options.base),
// Make empty directories browsable.
connect.directory(options.base)
];
};
grunt.loadNpmTasks("grunt-jslint");
// grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-open');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jslint: {
config: {
src: ['package.json', 'Gruntfile.js'],
directives: {
maxlen: 100,
indent: 2,
maxerr: 3,
predef: [
'module'
]
}
},
client: {
src: ['renderjs.js'],
directives: {
maxlen: 79,
indent: 2,
maxerr: 3,
unparam: true,
predef: [
'RSVP',
'window',
'document',
'DOMParser',
'Channel',
'XMLHttpRequest',
'MutationObserver',
'Blob',
'FileReader',
'Node',
'navigator',
'Event',
'URL'
]
}
},
test: {
src: ['test/embedded.js', 'test/renderjs_test.js',
'test/inject_script.js',
'test/embedded_crashing_service.js',
'test/embedded_fails.js',
'test/mutex_test.js', 'test/not_declared_gadget.js',
'test/trigger_rjsready_event_on_ready_gadget.js'],
directives: {
maxlen: 79,
indent: 2,
maxerr: 3,
unparam: true,
predef: [
'window',
'document',
'QUnit',
'renderJS',
'rJS',
'__RenderJSGadget',
'sinon',
'RSVP',
'DOMParser',
'URI',
'URL',
'__RenderJSIframeGadget',
'__RenderJSEmbeddedGadget',
'FileReader',
'Blob',
'Event',
'MutationObserver'
]
}
}
},
concat: {
options: {
separator: ';'
},
dist: {
src: ['<%= curl.jschannel.dest %>',
'<%= curl.domparser.dest %>',
'lib/iefix/*.js',
'renderjs.js'],
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
}
},
uglify: {
renderjs: {
src: "<%= concat.dist.dest %>",
dest: "dist/<%= pkg.name %>-<%= pkg.version %>.min.js"
}
},
copy: {
latest: {
files: [{
src: '<%= concat.dist.dest %>',
dest: "dist/<%= pkg.name %>-latest.js"
/*
}, {
src: '<%= uglify.renderjs.dest %>',
dest: "dist/<%= pkg.name %>-latest.min.js"
*/
}]
}
},
watch: {
src: {
files: [
'<%= jslint.client.src %>',
'<%= jslint.config.src %>',
'<%= jslint.test.src %>',
['lib/**'],
['test/*.html', 'test/*.js']
],
tasks: ['default'],
options: {
livereload: LIVERELOAD_PORT
}
}
},
curl: {
domparser: {
src: 'https://gist.github.com/eligrey/1129031/raw/' +
'e26369ee7939db745087beb98b4bb4bbcf460cf3/html-domparser.js',
dest: 'lib/domparser/domparser.js'
},
jschannel: {
src: 'http://mozilla.github.io/jschannel/src/jschannel.js',
dest: 'lib/jschannel/jschannel.js'
}
},
qunit: {
all: ['test/index.html']
},
connect: {
client: {
options: {
port: 9000,
base: '.',
directory: '.',
middleware: livereloadMiddleware
}
}
},
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:<%= connect.client.options.port%>/test/'
}
}
});
grunt.registerTask('default', ['all']);
grunt.registerTask('all', ['lint', 'build']);
grunt.registerTask('lint', ['jslint']);
grunt.registerTask('test', ['qunit']);
grunt.registerTask('server', ['connect:client', 'watch']);
grunt.registerTask('build', ['concat', 'copy']);
};