-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
145 lines (131 loc) · 3.65 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
'use strict';
module.exports = function (grunt) {
// Load grunt tasks automatically, when needed
require('jit-grunt')(grunt, {
express: 'grunt-express-server',
injector: 'grunt-injector'
});
// Define the configuration for all the tasks
grunt.initConfig({
synergy: {
// configurable paths
src: 'client',
dist: 'dist'
},
express: {
options: {
port: process.env.PORT || 9000
},
dev: {
options: {
script: 'server.js',
debug: true
}
},
prod: {
options: {
script: 'server.js',
debug: false
}
}
},
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
}
},
env: {
dev: {
NODE_ENV : 'development'
},
prod: {
NODE_ENV : 'production'
}
},
watch: {
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
files: [
'{.tmp,<%= synergy.src %>}/{app,components}/**/*.css',
'{.tmp,<%= synergy.src %>}/{app,components}/**/*.html',
'{.tmp,<%= synergy.src %>}/{app,components}/**/*.js',
'!{.tmp,<%= synergy.src %>}{app,components}/**/*.spec.js',
'!{.tmp,<%= synergy.src %>}/{app,components}/**/*.mock.js'
],
options: {
livereload: true
}
},
express: {
files: [
'server/**/*.{js,json}'
],
tasks: ['express:dev', 'wait'],
options: {
livereload: true,
nospawn: true //Without this option specified express won't be reloaded
}
}
},
// Automatically inject Bower components into the app
wiredep: {
target: {
src: '<%= synergy.src %>/../server/views/pages/index.ejs',
ignorePath: '../../../<%= synergy.src %>',
exclude: [/bootstrap-sass-official/, /bootstrap.js/, '/jquery/', '/json3/', '/es5-shim/', /bootstrap.css/, /font-awesome.css/,'/datatables/media/css/','/pdfjs-dist/build/' ]
}
},
injector: {
options: {
lineEnding: grunt.util.linefeed
},
// Inject application script files into index.html (doesn't include bower)
scripts: {
options: {
transform: function(filePath) {
filePath = filePath.replace('/client/', '');
filePath = filePath.replace('/.tmp/', '');
return '<script src="' + filePath + '"></script>';
},
starttag: '<!-- injector:js -->',
endtag: '<!-- endinjector -->',
lineEnding: grunt.util.linefeed
},
files: {
'<%= synergy.src %>/../server/views/pages/index.ejs': [
['{.tmp,<%= synergy.src %>}/app/{common,config}/**/*.js',
'{.tmp,<%= synergy.src %>}/app/components/**/*.routes.js',
'!{.tmp,<%= synergy.src %>}/app/app.js',
'!{.tmp,<%= synergy.src %>}/{app}/**/*.spec.js',
'!{.tmp,<%= synergy.src %>}/{app}/**/*.mock.js']
]
}
},
}
});
// Used for delaying livereload until after server has restarted
grunt.registerTask('wait', function () {
grunt.log.ok('Waiting for server reload...');
var done = this.async();
setTimeout(function () {
grunt.log.writeln('Done waiting!');
done();
}, 1500);
});
grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
this.async();
});
grunt.registerTask('serve', function (target) {
grunt.task.run([
'env:dev',
'injector',
'wiredep',
'express:dev',
'wait',
'open',
'watch'
]);
});
};