-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
269 lines (238 loc) · 6.8 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
bower: {
install: {
options: {
targetDir: './public/libs/vendors',
// layout: 'byType',
install: true,
verbose: true,
cleanTargetDir: false,
cleanBowerDir: false,
bowerOptions: {}
}
}
},
uglify: {
minlib: {
options:{
preserveComments: 'all'
},
files: {
'./public/backbone-wizard.min.js': ['public/js/common/backbone-wizard.js']
}
}
},
clean: {
pre: {
src: ['./public/js/main-built.*', './public/js/tpl/*']
},
bower: {
src: ['./public/libs/vendors/*']
}
},
copy: {
main: {
expand: true,
flatten: true,
src: './public/libs/vendors/requirejs/require.js',
dest: './public/libs',
filter: 'isFile'
}
},
// TODO: improve jasmine with helpers
jade: {
apps: {
files: {
'./public/js/tpl/': './public/js/**/**/**/**/*.jade'
},
options: {
basePath: './public/js/',
wrap: {
wrap: true,
amd: true,
node: false,
dependencies: 'jade'
},
runtime: false
}
}
},
jasmine : {
require : {
src : './public/js/',
options : {
specs : './spec/**/*.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: './public/js/config.js'
}
}
}
},
jshint: {
options: {
bitwise:true,
// Prohibit bitwise operators (&, |, ^, etc.).
curly:true,
// Require {} for every new block or scope.
eqeqeq:false,
// SET TO TRUE
// Require triple equals i.e. `===`.
immed:true,
// Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
latedef:true,
// Prohibit variable use before definition.
newcap:true,
// Require capitalization of all constructor functions e.g. `new F()`.
noarg:true,
// Prohibit use of `arguments.caller` and `arguments.callee`.
undef:true,
// Require all non-global variables be declared before they are used.
unused:true,
// Warns when you define and never use your variables.
debug:false,
// Allow debugger statements e.g. browser breakpoints.
validthis: true,
// Allow use of this
'-W065': true,
// Avoid radix on Parse()
// == Environments ====================================================
browser:true,
// Standard browser globals e.g. `window`, `document`.
jquery:true,
// Enable globals exposed by jQuery JavaScript library.
devel:true,
// Allow development statements e.g. `console.log();`.
// == JSLint Legacy ===================================================
// onevar:true,
// Allow only one `var` statement per function.
strict:false,
laxcomma: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true,
node: true,
// Check identation
// indent: 2,
globals: {
window: true,
document: true,
location: true,
define: true,
require: true,
requirejs: true,
// MUST BE REMOVED
moment: true,
//download.js
download: true,
// Here places global words that not need tobe defined
$: true,
_:true,
d3: true
},
},
all: [
'./public/js/apps/**/**/*.js',
'./public/js/common/**/**/*.js'
]
},
processhtml: {
dev: {
files: {
'./public/index.htm': ['./resources/index_base.htm']
}
},
prod: {
files: {
'./public/index.htm': ['./resources/index_base.htm']
}
}
},
// TODO: improve require with compress
requirejs: {
app: {
options: {
name:'config',
baseUrl: './public/js',
mainConfigFile: "./public/js/config.js",
out: "./public/js/main-built.js",
preserveLicenseComments: false,
inlineText: false,
findNestedDependencies: true,
skipModuleInsertion: false,
}
}
},
sass: {
dev: { // Target
options: {
// outputStyle: 'nested'
outputStyle: 'compressed'
},
files: { // Dictionary of files
'./public/css/style.min.css': './resources/stylesheets/style.scss' // 'destination': 'source'
}
}
},
// WATCH TASK
watch: {
options: {
event: ['added', 'changed']
},
jade: {
files: ['./public/js/**/*.jade'],
tasks: ['newer:jade']
},
test: {
files: ['./public/js/**/*.js'],
tasks: ['jasmine']
},
style: {
files: ['./resources/**/*.scss'],
tasks: ['sass']
},
jasmine: {
files: ['./spec/**/*.js'],
tasks: ['jasmine']
}
}
});
// EXTERNAL PLUGINS //
// Minify and disturb JS files
grunt.loadNpmTasks('grunt-contrib-uglify');
// JS Code quality
grunt.loadNpmTasks('grunt-contrib-jshint');
// Watcher, execute multiple task when a file has been changed
grunt.loadNpmTasks('grunt-contrib-watch');
// Let grunt compile Sass Css preprocessors files
grunt.loadNpmTasks('grunt-sass');
// Compile Jade templates to HTML !!!IMPORTANT there is another contrib from jade to HTML
grunt.loadNpmTasks('grunt-jade');
// Remove files
grunt.loadNpmTasks('grunt-contrib-clean');
// watch newer files
grunt.loadNpmTasks('grunt-newer');
// Testing Js code using Jasmine and Phantom
grunt.loadNpmTasks('grunt-contrib-jasmine');
// For building the static application
grunt.loadNpmTasks('grunt-contrib-requirejs');
// Compress & minify CSS not work on windows IDNK
// grunt.loadNpmTasks('grunt-contrib-cssmin');
// Load Bower.json
grunt.loadNpmTasks('grunt-bower-task');
// Let move files
grunt.loadNpmTasks('grunt-contrib-copy');
// Set dist or dev environment
grunt.loadNpmTasks('grunt-processhtml');
// TASKS //
// production task using uglify
grunt.registerTask('production', ['bower', 'clean:pre', 'sass', 'copy', 'jade', 'processhtml:prod', 'requirejs:app']);
// default task
grunt.registerTask('default', ['uglify', 'bower', 'jshint:all', 'clean:pre', 'copy', 'sass', 'jade', 'processhtml:dev']);
// test task
grunt.registerTask('test', ['jshint', 'jasmine']);
};