-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
168 lines (155 loc) · 4.79 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
module.exports = function(grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
// Project settings
hugbot: {
// Configurable paths
app: 'app',
dist: 'dist'
},
pkg: grunt.file.readJSON('package.json'),
// uglify: {
// options: {
// banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
// },
// build: {
// src: 'src/<%= pkg.name %>.js',
// dest: 'build/<%= pkg.name %>.min.js'
// }
// },
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= hugbot.dist %>/*',
'!<%= hugbot.dist %>/.git*'
]
}]
},
server: '.tmp'
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
options: {
dest: '<%= hugbot.dist %>'
},
html: '<%= hugbot.app %>/index.html'
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
options: {
assetsDirs: ['<%= hugbot.dist %>']
},
html: ['<%= hugbot.dist %>/{,*/}*.html'],
css: ['<%= hugbot.dist %>/css/{,*/}*.css']
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= hugbot.app %>',
dest: '<%= hugbot.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'img/{,*/}*.webp',
'{,*/}*.html',
'fonts/{,*/}*.*'
]
}]
},
styles: {
expand: true,
dot: true,
cwd: '<%= hugbot.app %>/css',
dest: '.tmp/css/',
src: '{,*/}*.css'
}
},
pleeease: {
custom: {
options: {
autoprefixer: {'browsers': ['last 4 versions', 'ios 6']},
filters: {'oldIE': true},
rem: ['12px'],
minifier: false,
mqpacker: true
},
files: {
'.tmp/css/base.css': '.tmp/css/base.css'
}
}
},
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= hugbot.dist %>/js/{,*/}*.js',
'<%= hugbot.dist %>/css/{,*/}*.css'
]
}
}
},
// The following *-min tasks produce minified files in the dist folder
imagemin: {
options: {
cache: false
},
dist: {
files: [{
expand: true,
cwd: '<%= hugbot.app %>/img',
src: '{,*/}*.{gif,jpeg,jpg,png}',
dest: '<%= hugbot.dist %>/img'
}]
}
},
htmlmin: {
dist: {
options: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeCommentsFromCDATA: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
useShortDoctype: true
},
files: [{
expand: true,
cwd: '<%= hugbot.dist %>',
src: '{,*/}*.html',
dest: '<%= hugbot.dist %>'
}]
}
}
});
grunt.registerTask(
'build', [
'clean:dist',
'useminPrepare',
'copy:styles',
'pleeease',
'imagemin',
'concat',
'cssmin',
'uglify',
'copy:dist',
'rev',
'usemin',
'htmlmin'
]);
};