-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
executable file
·218 lines (210 loc) · 6.92 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
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**********************************************
******* running jslint to all js files *******
**********************************************/
jslint: {
all: {
src: [
'js/main.js',
'js/modules/*.js',
'Gruntfile.js'
],
exclude: [
//'js/modules/datebox.js',
'js/modules/pmapi.js'
],
directives: { // example directives
browser: true,
unparam: true,
maxlen: 80,
indent: 2,
nomen: true,
predef: [
'$',
'jIO',
'alert',
'jQuery',
'window',
'parent',
'define',
'require',
'module',
'console',
'confirm',
'location',
'document',
'setTimeout',
'inserttasks',
'localStorage',
'displaytasks',
'insertprojects'
]
},
options: {
failOnError: false
}
}
},
/**********************************************
******* running jslint to all js files *******
**********************************************/
requirejs: {
compile: {
options: {
appDir: "./",
// => INFO: directory path = PRODUCTION folder
dir: "dir",
config: {
text: {
removeWhitespace: true
}
},
mainConfigFile: "js/main.js",
// INFO => base url for all js file
baseUrl: "js",
paths: {
//plugins (require-css, text, json)
css: "plugins/requirejs-plugins/require-css/css",
normalize: "plugins/requirejs-plugins/require-css/normalize",
text: "plugins/requirejs-plugins/text/text",
json: "plugins/requirejs-plugins/json/json",
i18next: "plugins/i18next/i18next-1.7.1",
//librairies (jquery, jquery mobile, jio)
jquery: "lib/jquery/jquery-1.10.1",
jqm: "lib/jquerymobile/jquery.mobile-1.4.0pre",
sha256: "lib/jio/sha256.amd",
rsvp: "lib/jio/rsvp-custom.amd",
jio: "lib/jio/jio",
complex_queries: "lib/jio/complex_queries",
localstorage: "lib/jio/localstorage",
davstorage: "lib/jio/davstorage",
erp5storage: "lib/jio/erp5storage",
gidstorage: "lib/jio/gidstorage",
replicatestorage: "lib/jio/replicatestorage",
overrides: "modules/overrides"
},
shim: {
"jquery": {exports: "$"},
"i18next": {deps: ["jquery"]},
"jqm": { deps: ["jquery"], exports: "mobile" },
"overrides": {deps: ["jquery"]}
},
map: {
"*": {"css": "plugins/requirejs-plugins/require-css/css"}
},
//built code is transformed in some way.
keepBuildDir: true,
optimize: "uglify2",
//optimize: "none",
skipDirOptimize: false,
//source maps as ".js.src" files.
generateSourceMaps: false,
normalizeDirDefines: "skip",
//-"standard.keepComments.keepLines": keeps the file comments & line
optimizeCss: "standard",
inlineText: true,
useStrict: false,
//together.
skipModuleInsertion: false,
//will be placed on another domain.
optimizeAllPluginResources: false,
//by default.
findNestedDependencies: true,
//If set to true, any files that were combined into a build
//layer will be removed from the output folder.
removeCombined: true,
//only the root bundles will be included unless the locale:
//section is set above.
/*modules: [
{
name: "modules/pmapi",
exclude: ["rsvp"]
//include: ["css", "i18next", "jio", "complex_queries", "jqm", "overrides", "rsvp", "sha256", "localstorage"]
}
],*/
//RegExp via new RegExp().
fileExclusionRegExp: /^(dir|node_modules|grunt|package|Gruntfiles|test)$/,
//work out how best to surface the license information.
preserveLicenseComments: false,
//Sets logging level.It's a number.If you want "silent" running,
logLevel: 0,
//this option
throwWhen: {
//If there is an error calling the minifier for some JavaScript,
//instead of just skipping that file throw an error.
optimize: true
},
//read in the disables the waiting interval.
waitSeconds: 3
}
}
},
/**************************************************
**** running html validation to all html files ****
**************************************************/
validation: {
files: {
src: ['*.html']
}
},
/**************************************************
**** running html validation to all html files ****
**************************************************/
jsonlint: {
sample: {
src: [ 'data/tasks.json' ]
}
},
/******************************************************
********* Generate HTML5 Cache Manifest files *********
*******************************************************/
manifest: {
generate: {
options: {
basePath: "./",
cache: [
"js/modules/pmapi.js",
"js/main.js",
"js/lib/requirejs/require.js",
"js/lib/jquerymobile/images/ajax-loader.gif",
"js/lib/jquerymobile/images/icons-18-black.png",
"js/lib/jquerymobile/images/icons-18-white.png",
"js/lib/jquerymobile/images/icons-36-black.png",
"js/lib/jquerymobile/images/icons-36-white.png",
"favicon.png",
"js/lib/jquerymobile/images/home.png",
"lang/en/translation.json",
"lang/fr/translation.json",
"lang/ch/translation.json"
],
network: ["http://*", "https://*"],
//exclude: ["js/jquery.min.js"],
preferOnline: true,
verbose: true,
timestamp: true
},
src: [
"*.html"
],
dest: "dir/manifest.appcache"
}
}
});
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-html-validation');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-manifest');
grunt.registerTask(
'default',
[ 'jslint',
'requirejs',
'validation',
'jsonlint',
'manifest'
]
);
};