forked from frePPLe/frepple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
192 lines (182 loc) · 7.41 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
/* Copyright (C) 2015 by frePPLe bv
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function themeconfig(themefolder, themename) {
// Auxilary function to generate the task configuration for a single theme.
var cfg = {
options: {
paths: [
themefolder + '/static/css/' + themename, // frePPLe theme folder
'freppledb/common/static/css', // frePPLe folder
'node_modules/bootstrap/less' // bootstrap folder
],
strictMath: true,
compress: true,
relativeUrls: true,
plugins: [
new(require('less-plugin-autoprefix'))({
browsers: ["last 2 versions"]
})
]
},
files: {}
}
cfg.files[themefolder + '/static/css/' + themename + '/bootstrap.min.css'] = [
'freppledb/common/static/css/frepple.less', // Generic frePPLe styles
themefolder + '/static/css/' + themename + '/frepple.less' // Theme specific styles
]
return cfg;
}
// Grunt configuration
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Less compilation
less: {
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 .less file changes we automatically run the "less"-task.
watch: {
files: ["**/*.less"],
tasks: ["less"]
},
// 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'
]
}
},
},
// 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/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/networkstatusDrv.js'
],
dest: 'freppledb/input/static/js/frepple-operationplandetail.js'
}
},
// Uglify the javascript files
uglify: {
options: {
sourceMap: true,
banner: '/* frePPLe <%= pkg.version %>\n' +
'Copyright (C) 2010-2019 by frePPLe bv\n\n' +
'This library is free software; you can redistribute it and/or modify it\n' +
'under the terms of the GNU Affero General Public License as published\n' +
'by the Free Software Foundation; either version 3 of the License, or\n' +
'(at your option) any later version.\n\n' +
'This library is distributed in the hope that it will be useful,\n' +
'but WITHOUT ANY WARRANTY; without even the implied warranty of\n' +
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n' +
'General Public License for more details.\n\n' +
'You should have received a copy of the GNU Affero General Public\n' +
'License along with this program. If not, see <http://www.gnu.org/licenses/>.\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'
}
},
// 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'
]
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-less');
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', ['less', 'concat', 'uglify', 'clean']);
};