-
Notifications
You must be signed in to change notification settings - Fork 11
/
imagemin.js
48 lines (44 loc) · 1.61 KB
/
imagemin.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
module.exports = function(grunt) {
grunt.initConfig({
imagemin: {
png: {
options: {
optimizationLevel: 3
},
files: [
{
// Set to true to enable the following options…
expand: true,
// cwd is 'current working directory'
cwd: 'assets/images/',
src: ['**/*.png'],
// Could also match cwd line above. i.e. project-directory/img/
dest: '.assets/images/',
ext: '.png'
}
]
},
jpg: {
options: {
progressive: true
},
files: [
{
// Set to true to enable the following options…
expand: true,
// cwd is 'current working directory'
cwd: 'assets/images/',
src: ['**/*.jpg'],
// Could also match cwd. i.e. project-directory/img/
dest: 'assets/images/',
ext: '.jpg'
}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.registerTask('default', ['imagemin']); // execute on both .png and .jpg
grunt.registerTask('imagepng', ['imagemin:png']); // only .png files
grunt.registerTask('imagejpg', ['imagemin:jpg']);// only .jpg files
}