forked from datarhei/restreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
187 lines (164 loc) · 5.76 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
'use strict';
// path to store the transpiled es6 files
const transpiledPath = "src/webserver/transpiled/";
const files = {
//workaround to keep correct order
transpiledFrontendJs: [
`${transpiledPath}/webserver/public/scripts/App.js`,
`${transpiledPath}/webserver/public/scripts/App.Config.js`,
`${transpiledPath}/webserver/public/scripts/Main/MainModule.js`,
`${transpiledPath}/webserver/public/scripts/Main/MainController.js`,
`${transpiledPath}/webserver/public/scripts/Login/LoginModule.js`,
`${transpiledPath}/webserver/public/scripts/Login/LoginController.js`,
`${transpiledPath}/webserver/public/scripts/Header/HeaderModule.js`,
`${transpiledPath}/webserver/public/scripts/Header/HeaderController.js`,
`${transpiledPath}/webserver/public/scripts/Header/HeaderDirective.js`,
`${transpiledPath}/webserver/public/scripts/Footer/FooterModule.js`,
`${transpiledPath}/webserver/public/scripts/Footer/FooterController.js`,
`${transpiledPath}/webserver/public/scripts/Footer/FooterDirective.js`,
`${transpiledPath}/webserver/public/scripts/StreamingInterface/StreamingInterfaceModule.js`,
`${transpiledPath}/webserver/public/scripts/StreamingInterface/StreamingStatusController.js`,
`${transpiledPath}/webserver/public/scripts/StreamingInterface/StreamingStatusDirective.js`,
`${transpiledPath}/webserver/public/scripts/Shared/LoggerService.js`,
`${transpiledPath}/webserver/public/scripts/Shared/WebsocketsService.js`
],
es6Src: [
'webserver/public/scripts/**/*.js'
],
stylesheets: ['src/webserver/public/css/*.css']
};
module.exports = function (grunt) {
// Project Configuration
grunt.initConfig({
/*
Config for shell commands
*/
shell: {
start: {
command: 'npm start'
},
removeTempTranspilingFolder: {
command: `rm -Rf ${transpiledPath}`
},
createTempTranspilingFolder: {
command: `mkdir ${transpiledPath}`
},
bower: {
command: 'bower install --allow-root'
},
eslint: {
command: 'eslint src/*'
},
//temp workaround - https://github.com/clappr/clappr/issues/709
clappr: {
command: 'rm -rf src/webserver/public/libs/clappr && git clone --depth 1 git://github.com/clappr/clappr src/webserver/public/libs/clappr'
}
},
/*
Config for Babel compiling
*/
babel: {
options: {
sourceMap: true,
presets: ['es2015']
},
all: {
files: [
{
expand: true,
cwd: 'src/',
src: '<%= es6Src %>',
dest: transpiledPath
}
]
}
},
/*
Config for eslinter
*/
eslint: {
all: ['src/**/*.js'],
options: {
configFile: '.eslintrc.json'
}
},
/*
config for css linter
*/
csslint: {
options: {
csslintrc: '.csslintrc'
},
all: {
src: ['src/webserver/public/css/*.css']
}
},
/*
uglify and minify frontend javascript
*/
uglify: {
production: {
options: {
mangle: true
},
files: {
'src/webserver/public/dist/application.min.js': 'src/webserver/public/dist/application.js'
}
}
},
/*
minify css files
*/
cssmin: {
combine: {
files: {
'src/webserver/public/css/restreamer.min.css': '<%= stylesheets %>'
}
}
},
/*
produces one file from all fontend javascript bewaring DI naming of angular
*/
ngAnnotate: {
production: {
files: {
'src/webserver/public/dist/application.js': '<%= transpiledFrontendJs %>'
}
}
}
});
/*
Load NPM tasks
*/
require('load-grunt-tasks')(grunt);
grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function () {
grunt.config.set('es6Src', files.es6Src);
grunt.config.set('transpiledFrontendJs', files.transpiledFrontendJs);
grunt.config.set('stylesheets', files.stylesheets);
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-watch');
/*
Helper tasks to keep overview
*/
// lint
grunt.registerTask('lint', ['csslint', 'shell:eslint']);
// clear old transpile folder and create new one
grunt.registerTask('clearOldBuild', ['shell:removeTempTranspilingFolder', 'shell:createTempTranspilingFolder']);
// install frontendlibraries (atm through bower)
grunt.registerTask('installFrontendLibraries', ['shell:bower', 'shell:clappr']);
// minify the frontend files
grunt.registerTask('minifyFrontendFiles', ['cssmin', 'ngAnnotate', 'uglify']);
/*
Build Tasks
*/
grunt.registerTask('build', ['loadConfig', 'clearOldBuild', 'babel', 'minifyFrontendFiles', 'installFrontendLibraries', 'shell:removeTempTranspilingFolder']);
/*
Just Compile
*/
grunt.registerTask('compile', ['loadConfig', 'clearOldBuild', 'babel', 'minifyFrontendFiles']);
/*
Run Tasks
*/
grunt.registerTask('run', ['shell:start']);
};