-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
271 lines (251 loc) · 7.63 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
270
271
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
/* MISE À JOUR DES PACKAGES CONTENUS DANS PACKAGE.JSON */
devUpdate: {
options: {
updateType: 'report', //just report outdated packages
reportUpdated: false, //don't report already updated packages
semver: true, //use package.json semver rules when updating
packages: { //what packages to check
devDependencies: true, //only devDependencies
dependencies: false
},
packageJson: null //find package.json automatically
}
},
/* AUTOMATISATION */
watch: {
//all: {
// options: { livereload: true, spawn: false },
// files: ['source/**/*']
//},
html: {
files: ['src/**/*.html'],
tasks: ['copy'],
options: {
livereload: true
}
},
img: {
files: ['src/img/**/*.png', 'src/img/**/*.jpg', 'src/img/**/*.gif'],
tasks: ['imagemin:dev'],
options: {
livereload: true
}
},
js: {
files: ['src/**/*.js'],
tasks: ['jshint'/*, 'concat.dev'*/, 'uglify:dev'],
options: {
livereload: true
}
},
scss: {
files: ['src/**/*.scss'],
tasks: ['sass:dev'/*, 'csslint'*/],
options: {
livereload: true
}
}
},
karma: {
unit: {
configFile: 'karma.conf.js',
background: true
}
},
/* TRANSFORMATION DU CODE */
sass: {
dev: {
options: { // Target options
style: 'expanded'
},
files: { // Dictionary of files
'www/css/style.css': 'src/scss/style.scss'//, // 'destination': 'source'
//'widgets.css': 'widgets.scss'
}
},
build: {
options: {
style: 'compressed',
noCache: true,
banner: '/*! <%= pkg.appname %> version <%= pkg.appversion %> */\n',
},
files: {
'src/<%= pkg.appname %>.scss': ['build/css/<%= pkg.appname %>.css']
}
}
},
/* VERIFICATION DU CODE */
jshint: {
src: ['src/**/*.js']
},
csslint: {
dev: {
options: {
import: 2
},
src: ['www/css/style.css']
},
build: {
options: {
import: 2
},
src: ['build/css/style.css']
}
},
/* MISE EN FORME DES FICHIERS */
//concat: {
// options: {
// stripBanners: true,
// banner: '/*! <%= pkg.appname %> version <%= pkg.appversion %> concatened */\n',
// },
// dev: {
// src: ['src/**/*.js'],
// dest: 'dev/js/<%= pkg.appname %>.js'
// },
// build: {
// src: ['src/**/*.js'],
// dest: 'build/js/<%= pkg.appname %>.js'
// }
//},
uglify: {
dev: {
options: {
mangle: false,
compress: false,
beautify: true
},
files: {
//'www/js/output.min.js': ['src/**/*.js']
'www/js/output.min.js': ['src/js/app.js', 'src/js/controllers.js', 'src/js/services.js', 'src/js/directives.js', 'src/js/calculs.js']
}
},
build: {
options: {
mangle: false,
compress: true,
beautify: false
},
files: {
//'www/js/output.min.js': ['src/**/*.js']
'www/js/output.min.js': ['src/js/app.js', 'src/js/controllers.js', 'src/js/services.js', 'src/js/directives.js', 'src/js/calculs.js']
}
}
},
/*uglify: {
options: {
mangle: false
},
my_target: {
files: {
'dest/output.min.js': ['src/input.js']
}
}
},*/
autoprefixer: {
dev: {
src: 'dev/css/<%= pkg.appname %>.css',
},
build: {
src: 'build/css/<%= pkg.appname %>.css',
}
},
imagemin: {
dev: {
files: [{
expand: true,
cwd: 'src/img/',
src: ['*.{png,jpg,gif}'],
dest: 'www/img/'
}]
},
build: {
dynamic: {
files: [{
expand: true,
cwd: '/src/img/',
src: ['*.{png,jpg,gif}'],
dest: '/www/img/'
}]
}
}
},
copy: {
dev : {
files: [
{expand: true, src: ['src/*.html'], flatten: true, dest: 'www/'},
{expand: true, src: ['src/templates/*.html'], flatten: true, dest: 'www/templates/'}
]
},
build: {
files: [
{expand: true, src: ['src/*.html'], flatten: true, dest: 'www/'},
{expand: true, src: ['src/templates/*.html'], flatten: true, dest: 'www/templates/'}
]
}
},
/*main: {
files: [
// includes files within path
{expand: true, src: ['path/*'], dest: 'dest/', filter: 'isFile'},
// includes files within path and its sub-directories
{expand: true, src: ['path/**'], dest: 'dest/'},
// makes all src relative to cwd
{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'},
// flattens results to a single level
{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'}
]
} */
compress: {
build: {
options: {
archive: '<%= pkg.appname %>.src.<%= pkg.appversion %>.zip'
},
files: [
{expand: true, src: ['src/**'], dest: '.'}
]
},
package: {
options: {
archive: '<%= pkg.appname %>.<%= pkg.appversion %>.zip'
},
files: [
{expand: true, src: ['build/**'], dest: '.'}
]
}
},
'ftp-deploy': {
build: {
auth: {
host: 'server.com',
port: 21,
authKey: 'key1' // .ftppass
},
src: 'path/to/source/folder',
dest: '/path/to/destination/folder',
exclusions: ['build/**/.DS_Store', 'build/**/Thumbs.db', 'build/**/*.git*']
}
},
/* NETTOYAGE */
clean: ['build/js', 'build/css', 'build/img']
});
grunt.registerTask('default', ['devUpdate', 'watch']);
grunt.registerTask('dev', [/*'watch',*/ 'sass', 'jshint', /*'csslint',*/ /*'concat',*/ 'autoprefixer', 'uglify', 'imagemin']);
grunt.registerTask('build', ['sass', /*'concat', */'autoprefixer', 'uglify', 'imagemin', 'compress','ftp-deploy']);
grunt.registerTask('clean', ['clean']);
}
/*
TODO
----
files deleting
livereload deleting in build mode
karma tests
start a http server
launch chrome in a particular URL
download a mysql database
launch a xcode compilation
modify version number
launch a java compile
*/