-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
136 lines (125 loc) · 4.45 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
module.exports = function(grunt) {
grunt.initConfig({
// Process SCSS to CSS and put into staging directory
sass: {
develop: {
files: {
'css/main.css': 'scss/main.scss',
}
},
production: {
files: {
'css/main.css': 'scss/main.scss',
}
}
},
// Autoprefix CSS in staging directory and overwrite
autoprefixer: {
production: {
options: {
browsers: ['last 5 iOS versions', 'ie 8', 'ie 9', 'last 4 Chrome versions', 'last 4 Safari versions', 'last 4 Firefox versions', 'last 3 Android versions', 'last 3 Samsung versions', 'last 2 Edge versions'],
},
files: {
'css/main.css': 'css/main.css',
},
},
},
// Concatenate all JS files into 1 file and put into staging directory
concat: {
develop: {
src: ['js/velocity.min.js','js/*.js','!js/script.js'],
dest: 'js/script.js',
},
production: {
src: ['js/velocity.min.js','js/*.js','!js/script.js'],
dest: 'js/script.js',
}
},
// Minify CSS in staging directory and put into public directory
cssmin: {
production: {
files: {
'public/min/main.css': 'css/main.css',
}
}
},
// Minify JS in staging directory and put into public directory. Minify 3rd party JS and put into public
uglify: {
production: {
files: [
{src: ['js/script.js'], dest: 'public/min/script.js'},
{src: ['bin/nanogallery2/jquery.nanogallery2.min.js'], dest: 'public/bin/min/jquery.nanogallery2.min.js'},
{src: ['bin/nanogallery2/jquery.nanogallery2.data_flickr.min.js'], dest: 'public/bin/min/jquery.nanogallery2.data_flickr.min.js'},
],
}
},
// Process HTML to use minified objects and put into public directory
processhtml: {
options: {
process: true,
},
production: {
files: {
'public/index.html': 'index.html',
}
}
},
// Minify HTML in public directory and overwrite
htmlmin: {
production: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: [{
expand: true, // Enable dynamic expansion.
cwd: 'public/', // Src matches are relative to this path.
src: ['*.html'], // Actual pattern(s) to match.
dest: 'public/', // Destination path prefix.
}],
},
},
imagemin: {
production: {
options: {
optimizationLevel: 4,
},
files: [{
expand: true,
cwd: 'images/',
src: ['*.jpg'],
dest: 'public/images/',
}],
},
},
/*
image: {
options: {
mozjpeg: ['--quality', 85],
},
production: {
options: {
jpegRecompress: false,
mozjpeg: true,
},
files: [{
expand: true,
cwd: 'public/images/',
src: ['*.jpg'],
dest: 'public/images/',
}],
}
} */
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-image');
grunt.registerTask('develop', ['sass:develop','concat:develop']);
grunt.registerTask('production', ['sass:production','autoprefixer','cssmin','concat:production','uglify','processhtml','htmlmin','imagemin']);
};