-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·83 lines (79 loc) · 2.41 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
module.exports = function (grunt) {
grunt.initConfig({
main: {
files: {
js: 'src/js/main.js',
css: 'src/css/main.css',
html: 'src/html/index.html'
}
},
jshint: {
files: ['Gruntfile.js', '<%= main.files.js %>'],
options: {
globals: {
jQuery: true
}
}
},
uglify: {
min: {
files: grunt.file.expandMapping([
'src/js/*.js'
],
'min/js/',
{
rename: function (src, dest) {
var filename = src + dest.replace('.js', '.min.js');
filename = filename.replace('src/js/', '');
return filename;
}
}
)
}
},
cssmin: {
min: {
files: {
'min/css/main.min.css': ['<%= main.files.css %>']
}
}
},
htmlmin: {
min: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'index.html': '<%= main.files.html %>'
}
}
},
imagemin: {
dist: {
options: {
optimizationLevel: 5
},
files: [{
expand: true,
cwd: 'src/images',
src: ['**/*.{png,jpg,gif,ico}'],
dest: 'min/images'
}]
}
},
watch: {
files: ['Gruntfile.js', '<%= main.files.js %>', '<%= main.files.css %>', '<%= main.files.html %>'],
tasks: ['jshint', 'uglify', 'cssmin', 'htmlmin:min']
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-watch');
// Register tasks
grunt.registerTask('default', ['jshint', 'uglify', 'cssmin', 'htmlmin:min', 'watch']);
};