This repository was archived by the owner on Sep 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathGruntfile.js
182 lines (168 loc) · 6.39 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
/** changes to the source files trigger a karma retest
*/
sourceChanged: {
files: ['jsapp/kobo/**/*.js', 'jsapp/kobo/**/*.coffee', 'jsapp/kobo/**/*.html',
'jsapp/xlform_model_view/*.coffee', 'jsapp/xlform_model_view/*.js'],
options: { livereload: true },
},
htmlChanged: {
options: { livereload: true },
files: ['dkobo/koboform/templates/jasmine_spec.html'],
},
/** changes to the tests trigger a karma retest
*/
// testsChanged: {
// files: [
// // do we want to jump to all coffee tests?
// 'jsapp/test/**/*.js',
// 'jsapp/test/**/*.coffee'
// ],
// tasks: ['karma:unit'],
// },
/** dkobo_xlform.js is build with and AMD packaging module
* and is referenced by python and browser.
*
* Changes in the source directory should rebuild the file, which ends up
* eventually triggering 'sourceChanged' as well.
*/
retestXlform: {
files: ['jsapp/test/xlform/*.coffee'],
options: { livereload: true },
},
rebuildDkoboXlform: {
files: ['jsapp/xlform_model_view/**/*.js', 'jsapp/xlform_model_view/**/*.coffee'],
tasks: ['requirejs:compile_xlform'],
},
/** One of the scss files changed, which triggers a rebuild
* of the generated css files.
*/
scssChanged: {
files: ['jsapp/kobo/stylesheets/**/*.scss'],
tasks: ['build_css'],
options: { livereload: false },
},
// cssChanged: {
// files: ['jsapp/kobo.compiled/*.css', '!jsapp/**/*.verbose.css'],
// tasks: [],
// options: { livereload: true },
// },
livereload: {
options: { livereload: true },
files: ['jsapp/kobo/compiled/*.css', '!jsapp/**/*.verbose.css'],
},
},
karma: {
unit: {
configFile: 'jsapp/test/configs/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS'],
},
amd: {
/** It would be better to prevent the second karma server from
* starting altogether, instead of just changing the port,
* but that seems unattainable with multiple configuration files.
*/
port: 9877,
configFile: 'jsapp/test/configs/karma-amd.conf.js',
singleRun: true,
browsers: ['PhantomJS'],
},
},
requirejs: {
compile_xlform: {
options: {
baseUrl: 'jsapp',
// uglify-minimization/optimization--
optimize: 'none',
stubModules: ['cs'],
wrap: true,
exclude: ['coffee-script'],
name: 'almond',
include: 'build_configs/dkobo_xlform',
out: 'jsapp/kobo/compiled/dkobo_xlform.js',
paths: {
'almond': 'components/almond/almond',
'jquery': 'components/jquery/dist/jquery.min',
'cs' :'components/require-cs/cs',
// stubbed paths for almond build
'backbone': 'build_stubs/backbone',
'underscore': 'build_stubs/underscore',
'jquery': 'build_stubs/jquery',
'backbone-validation': 'components/backbone-validation/dist/backbone-validation-amd',
// 'backbone': 'components/backbone/backbone',
// 'underscore': 'components/underscore/underscore',
'coffee-script': 'components/require-cs/coffee-script',
// project paths
'xlform': 'xlform_model_view',
},
},
},
},
sass: {
dist: {
options: {
style: 'compact',
},
files: {
// scss does not get rid of duplicate rules and the style_modules has lots
// of duplicates so we must use cssmin afterwards.
'jsapp/kobo/compiled/kobo.verbose.css' : 'jsapp/kobo/kobo.scss',
},
},
},
cssmin: {
strip_duplicates: {
options: {
banner: "/* compiled from 'kobo/kobo.scss' and 'kobo/stylesheets' */",
keepBreaks: true,
},
files: {
'jsapp/kobo/compiled/kobo.css': ['jsapp/kobo/compiled/kobo.verbose.css'],
},
},
dist: {
options: {
banner: "/* kobo.css minified. scss source available on github: https://github.com/kobotoolbox/dkobo/ */",
report: ['min', 'gzip'],
},
files: {
'jsapp/kobo/compiled/kobo.min.css': ['jsapp/kobo/compiled/kobo.css'],
},
},
},
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('build', [
'requirejs:compile_xlform',
'build_css',
]);
grunt.registerTask('build_all', [
'build',
]);
grunt.registerTask('build_css', [
'sass:dist',
'cssmin:strip_duplicates',
'cssmin:dist',
]);
grunt.registerTask('test', [
'build',
'karma:unit',
'karma:amd',
]);
grunt.registerTask('develop', [
'requirejs:compile_xlform',
'build_css',
'watch',
]);
grunt.registerTask('default', [
'develop',
]);
};