-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
103 lines (95 loc) · 2.88 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
/*global module:false*/
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
var gruntConfig = {
buildinfo : {
input : 'input',
output : 'output',
debug : true ,
temp : 'temp' ,
env : 'local' ,
version_major : "1.0" ,
version_minor : ".0" ,
}
};
var opt = require('imagemin-optipng'),
multer = require('multer'),
serveStatic = require('serve-static');;
grunt.initConfig({
clean: ['output/*'],
imagemin: {
dynamic: {
options: {
optimizationLevel: 3,
svgoPlugins: [{ removeViewBox: false }],
use: [opt()]
},
files: [{
expand: true,
cwd: 'input/',
src: ['**/*.{png,jpg,gif}'],
dest: 'output/'
}]
}
},
guetzli: {
files: {
expand: true,
src: 'input/**/*.jpg',
dest: 'output/'
},
options: {
quality: 84,
verbose: true
}
},
compress: {
main: {
options: {
archive: 'output.zip',
pretty: true
},
files: [
// {src: ['output/*'], dest: 'internal_folder/', filter: 'isFile'}, // includes files in path
// {src: ['output/**'], dest: 'archive/'}, // includes files in path and its subdirs
{expand: true, cwd: 'output/', src: ['**'], dest: 'output/'}, // makes all src relative to cwd
// {flatten: true, src: ['path/**'], dest: 'internal_folder4/', filter: 'isFile'} // flattens results to a single level
]
}
},
connect: {
server: {
options: {
port: 9000,
protocol: 'http',
hostname: 'localhost',
open: true,
keepalive: true,
debug: true,
middleware: function(connect) {
console.log('foo');
return [
multer({dest: './www/input/'}),
serveStatic('./www/')
]
}
}
}
},
watch: {
files: ['www/input/**'],
tasks: ['test']
}
});
// Default task.
grunt.registerTask('i', ['clean','imagemin']);
grunt.registerTask('g',['clean','guetzli']);
grunt.registerTask('serve',[
'connect',
'watch'
]);
grunt.registerTask('test',function() {
console.log('test');
});
};