forked from frePPLe/frepple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
223 lines (211 loc) · 9.1 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
/* Copyright (C) 2015 by frePPLe bv
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
*/
const sass = require('node-sass');
function themeconfig(themefolder, themename) {
// Auxilary function to generate the task configuration for a single theme.
var cfg = {
options: {
implementation: sass,
includePaths: [
themefolder + '/static/css/' + themename, // frePPLe theme folder
'freppledb/common/static/css'//, // frePPLe folder
],
outputStyle: 'compressed'
},
files: {}
}
cfg.files[themefolder + '/static/css/' + themename + '/bootstrap.min.css'] = [
'freppledb/common/static/css/frepple.scss', // Generic frePPLe styles
themefolder + '/static/css/' + themename + '/frepple.scss' // Theme specific styles
]
return cfg;
}
// Grunt configuration
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// SASS compilation
sass: {
odoo: themeconfig('freppledb/common', 'odoo'),
grass: themeconfig('freppledb/common', 'grass'),
earth: themeconfig('freppledb/common', 'earth'),
lemon: themeconfig('freppledb/common', 'lemon'),
snow: themeconfig('freppledb/common', 'snow'),
strawberry: themeconfig('freppledb/common', 'strawberry'),
water: themeconfig('freppledb/common', 'water'),
orange: themeconfig('freppledb/common', 'orange'),
openbravo: themeconfig('freppledb/common', 'openbravo'),
},
// When any .scss file changes we automatically run the "sass"-task.
watch: {
files: ["**/*.scss"],
tasks: ["sass"]
},
// Extract translations
nggettext_extract: {
pot: {
options: {
msgmerge: true
},
files: {
'freppledb/common/static/common/po/template.pot': [
'freppledb/input/static/operationplandetail/*.html',
'freppledb/input/static/operationplandetail/src/*.js',
'freppledb/forecast/static/forecast/*.html',
'freppledb/forecast/static/forecast/src/*.js'
]
}
},
},
// Compile translations
nggettext_compile: {
all: {
files: {
'freppledb/common/static/js/i18n/angular-freppletranslations.js': [
'freppledb/common/static/common/po/*.po'
]
}
},
},
// Concatenate javascript files
concat: {
common: {
src: [
'freppledb/common/static/common/src/module.js',
'freppledb/common/static/common/src/webfactory.js',
'freppledb/common/static/common/src/preferences.js'
],
dest: 'freppledb/common/static/js/frepple-common.js'
},
input: {
src: [
'freppledb/input/static/input/src/module.js',
'freppledb/input/static/input/src/buffer.js',
'freppledb/input/static/input/src/demand.js',
'freppledb/input/static/input/src/customer.js',
'freppledb/input/static/input/src/item.js',
'freppledb/input/static/input/src/location.js',
'freppledb/input/static/input/src/operation.js',
'freppledb/input/static/input/src/operationplan.js',
'freppledb/input/static/input/src/resource.js',
'freppledb/input/static/input/src/model.js',
],
dest: 'freppledb/input/static/js/frepple-input.js'
},
operationplandetail: {
src: [
'freppledb/input/static/operationplandetail/src/calendar.js',
'freppledb/input/static/operationplandetail/src/module.js',
'freppledb/input/static/operationplandetail/src/operationplandetailCtrl.js',
'freppledb/input/static/operationplandetail/src/problemspanelDrv.js',
'freppledb/input/static/operationplandetail/src/resourcespanelDrv.js',
'freppledb/input/static/operationplandetail/src/bufferspanelDrv.js',
'freppledb/input/static/operationplandetail/src/demandpeggingpanelDrv.js',
'freppledb/input/static/operationplandetail/src/operationplanpanelDrv.js',
'freppledb/input/static/operationplandetail/src/supplyinformationDrv.js',
'freppledb/input/static/operationplandetail/src/downstreamoperationplansDrv.js',
'freppledb/input/static/operationplandetail/src/upstreamoperationplansDrv.js',
'freppledb/input/static/operationplandetail/src/kanbanDrv.js',
'freppledb/input/static/operationplandetail/src/ganttDrv.js',
],
dest: 'freppledb/input/static/js/frepple-operationplandetail.js'
},
forecast: {
src: [
'freppledb/forecast/static/forecast/src/module.js',
'freppledb/forecast/static/forecast/src/customerstable.js',
'freppledb/forecast/static/forecast/src/itemstable.js',
'freppledb/forecast/static/forecast/src/locationstable.js',
'freppledb/forecast/static/forecast/src/forecastgridDrv.js',
'freppledb/forecast/static/forecast/src/displayForecastGraph.js',
'freppledb/forecast/static/forecast/src/forecast.js'
],
dest: 'freppledb/forecast/static/js/frepple-forecast.js'
}
},
// Uglify the javascript files
uglify: {
options: {
sourceMap: true,
banner: '/* frePPLe <%= pkg.version %>\n' +
'Copyright (C) 2010-2019 by frePPLe bv\n\n' +
'Permission is hereby granted, free of charge, to any person obtaining\n' +
'a copy of this software and associated documentation files(the\n' +
'"Software"), to deal in the Software without restriction, including\n' +
'without limitation the rights to use, copy, modify, merge, publish,\n' +
'distribute, sublicense, and/ or sell copies of the Software, and to\n' +
'permit persons to whom the Software is furnished to do so, subject to\n' +
'the following conditions:\n' +
'\n' +
'The above copyright notice and this permission notice shall be\n' +
'included in all copies or substantial portions of the Software.\n' +
'\n' +
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\n' +
'EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n' +
'MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n' +
'NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n' +
'LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n' +
'OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n' +
'WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n' +
'*/\n'
},
js: {
src: ['freppledb/common/static/js/frepple.js'],
dest: 'freppledb/common/static/js/frepple.min.js'
},
common: {
src: ['freppledb/common/static/js/frepple-common.js'],
dest: 'freppledb/common/static/js/frepple-common.min.js'
},
input: {
src: ['freppledb/input/static/js/frepple-input.js'],
dest: 'freppledb/input/static/js/frepple-input.min.js'
},
operationplandetail: {
src: ['freppledb/input/static/js/frepple-operationplandetail.js'],
dest: 'freppledb/input/static/js/frepple-operationplandetail.min.js'
},
forecast: {
src: ['freppledb/forecast/static/js/frepple-forecast.js'],
dest: 'freppledb/forecast/static/js/frepple-forecast.min.js'
}
},
// Clean intermediate files
clean: [
'freppledb/common/static/js/frepple-common.js',
'freppledb/input/static/js/frepple-input.js',
'freppledb/input/static/js/frepple-operationplandetail.js',
'freppledb/forecast/static/js/frepple-forecast.js'
]
});
// Load tasks
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-exec');
// Register our tasks
grunt.registerTask('minify', ['concat', 'uglify', 'clean']);
grunt.registerTask('default', ['sass', 'concat', 'uglify', 'clean']);
};