-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·239 lines (213 loc) · 9.08 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
//banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
},
webapp: {
files: {
/*
* webapp-libs.tmp.min.js
*
* Libs used by the webapp.
* This file is temporary.
*/
'static/dist/js/webapp-libs.min.tmp.js': [
// libs
'static/src/js/lib/bootstrap-datepicker.js',
// i18n code
'static/src/js/locales/*.js'
],
/*
* webapp-scripts.min.js
*
* Webapp source code.
* This file is temporary.
*/
'static/dist/js/webapp-scripts.min.tmp.js': [
'static/src/js/app/app.js',
'static/src/js/app/directives.js',
'static/src/js/app/services.js',
'static/src/js/app/controllers/*',
'static/src/js/app/modules/*'
]
}
}
},
concat: {
nonull: true,
webapp: {
nonull: true,
files: {
/*
* script.min.js
*
* Base scripts used in the entire site.
*/
'static/dist/js/script.min.js': [
'static/bower_components/jquery/jquery.min.js',
'static/bower_components/bootstrap/dist/js/bootstrap.min.js'
],
/*
* webapp-libs.min.js
*
* Webapp dependencies.
* This file is temporary.
*/
'static/dist/js/webapp-libs.min.tmp.js': [
// bower
'static/bower_components/angular/angular.min.js',
'static/bower_components/angular-resource/angular-resource.min.js',
'static/bower_components/angular-ui-router/release/angular-ui-router.min.js',
'static/bower_components/angular-animate/angular-animate.min.js',
'static/bower_components/store.js/store.min.js',
'static/bower_components/angular-strap/dist/modules/dimensions.min.js',
'static/bower_components/angular-strap/dist/modules/modal.min.js',
'static/bower_components/angular-strap/dist/modules/tooltip.min.js',
'static/bower_components/angular-strap/dist/modules/popover.min.js',
'static/bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js',
'static/bower_components/toastr/toastr.min.js',
'static/bower_components/moment/min/moment.min.js',
'static/bower_components/bootstrap-select/bootstrap-select.min.js',
'static/bower_components/bootstrap-tour/build/js/bootstrap-tour.min.js',
'static/bower_components/accounting/accounting.min.js',
// not bower
'static/src/js/lib/min/highcharts.js',
'static/src/js/lib/min/modernizr.custom.19405.js',
'static/dist/js/webapp-libs.min.tmp.js'
],
/*
* webapp.min.js
*
* Webapp source code + dependencies.
*/
'static/dist/js/webapp-scripts.js': [
'static/dist/js/webapp-libs.min.tmp.js',
'static/dist/js/webapp-scripts.min.tmp.js'
]
}
}
},
clean: {
dist: ['static/dist/*'],
buildjs: [
'static/dist/js/webapp-libs.min.tmp.js',
'static/dist/js/webapp-scripts.min.tmp.js'
],
local_settings: ['core/local_settings.py', 'core/local_settings.pyc']
},
less: {
webapp: {
files: {
"static/src/css/styles.css": [
"static/less/webapp/styles.less"
]
}
},
landing: {
files: {
"static/src/css/landing.css": [
"static/less/landing/*.less"
]
}
}
},
watch: {
webapp: {
files: ['static/less/*.less', 'static/less/webapp/*.less', 'static/less/components/*.less', 'static/less/lib/*.less'],
tasks: ['less:webapp']
},
landing: {
files: ['static/less/*.less', 'static/less/landing/*.less'],
tasks: ['less:landing']
}
},
exec: {
makemessagesDjango: {
command: 'python manage.py makemessages -l pt_BR -i node_modules -i staticfiles -i static/dist'
},
makemessagesJS: {
command: 'python manage.py makemessages -l pt_BR -d djangojs -i node_modules -i staticfiles -i static/dist'
},
testserver: {
cmd: function runTestServer () {
var command = 'python manage.py testserver --addrport 0:{{port}} testserver_data.yaml';
var port = this.option('port') || 8001;
return command.replace('{{port}}', port);
}
},
foreman: {
command: 'python manage.py collectstatic --noinput; foreman start --port 8000'
}
},
copy: {
webapp: {
files: [
{src: 'img/**', dest: 'static/dist/', expand: true, cwd: 'static/src'},
{src: 'fonts/**', dest: 'static/dist/', expand: true, cwd: 'static/src'}
]
},
local_settings: {
files: [
{src: 'core/dev_settings/<%= grunt.option("file") || "dev" %>.py', dest: 'core/local_settings.py'}
]
}
},
cssmin: {
options: {
keepSpecialComments: 0
},
landing: {
files: {
'static/dist/css/landing.css': ['static/src/css/landing.css']
}
},
webapp: {
files: {
'static/dist/css/styles.css': ['static/src/css/styles.css', 'static/src/css/bootstrap-select.css']
}
}
},
replace: {
options: {
patterns: [
{
match: /\?rel=(\d+)/,
replacement: '?rel=<%= new Date().getTime() %>',
expression: false
}
]
},
webapp: {
files: [
{src: ['templates/webapp/index.html'], dest: 'templates/webapp/index.html'},
{src: ['templates/base.html'], dest: 'templates/base.html'},
{src: ['templates/landing.html'], dest: 'templates/landing.html'}
]
}
}
});
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-cssmin');
/*
* Task: buildjs
*
* Artifacts:
* script.min.js : the scripts for all pages (including the webapp).
* webapp.min.js : the entire webapp scripts, except global scripts.
*/
grunt.registerTask('build-webapp', 'Builds the whole javascript used in production.', ['clean:dist', 'uglify:webapp', 'concat:webapp', 'clean:buildjs', 'copy:webapp', 'cssmin', 'replace']);
grunt.registerTask('makemessages', 'Make message files for both django and djangojs.', ['exec:makemessagesDjango', 'exec:makemessagesJS']);
grunt.registerTask('testserver', 'Runs the django testserver on port 8002 and loading the `testserver_data.yaml` fixture.', ['exec:testserver']);
grunt.registerTask('foreman', 'Colect static files and runs foreman on port 8000.', ['exec:foreman']);
grunt.registerTask('patch-settings', 'Patches the local settings file with a file in the `core/dev_settings` folder.', ['clean:local_settings', 'copy:local_settings']);
};