forked from buddycloud/webclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
58 lines (48 loc) · 1.55 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
var requirejs = require('requirejs')
var config = requirejs('./config.js')
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
testacular: {
unit: {
configFile: 'testacular.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},
watch: {}
});
// Plug-ins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('gruntacular');
// Tasks
grunt.registerTask('default', ['server']);
grunt.registerTask('server', ['_server', 'watch']);
grunt.registerTask('test', ['testacular']);
// Development Server
grunt.registerTask('_server', 'Start a custom static web server.', function() {
var express = require('express');
var fs = require('fs');
var mdir = __dirname;
var app = express();
app.use('/js', express.static(mdir + '/js'));
app.use('/css', express.static(mdir + '/css'));
app.use('/img', express.static(mdir + '/img'));
app.use('/locales', express.static(mdir + '/locales'));
app.use('/templates', express.static(mdir + '/templates'));
app.get('/config.js', function(req, res) {
fs.readFile(mdir + '/config.js', 'utf8', function(error, file) {
res.contentType('application/javascript');
res.send(file);
});
});
app.get('*', function(req, res) {
fs.readFile(mdir + '/index.html', 'utf8', function(error, file) {
res.send(file);
});
});
var port = config.port || 3000;
app.listen(port);
console.log('Listening on port ' + port + '...');
});
}