This repository has been archived by the owner on Feb 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
201 lines (181 loc) · 4.71 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
'use strict';
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('assemble'); // Doesn't follow the grunt-* naming scheme and therefore isn't loaded automatically
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
config: {
src: 'app',
dist: 'dist'
},
watch: {
assemble: {
files: ['<%= config.src %>/{content,data,templates}/{,*/}*.{md,hbs,yml,json}'],
tasks: ['assemble']
},
gruntfile: {
files: ['Gruntfile.js']
},
images: {
files: ['<%= config.src %>/assets/images/**/*.{png,jpg,jpeg,gif,webp,svg,ico}', '<%= config.src %>/images/*.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: false,
}
},
scripts: {
files: ['<%= config.src %>/assets/scripts/**/*'],
tasks: ['jshint', 'concat', 'uglify'],
options: {
spawn: false,
}
},
styles: {
files: ['<%= config.src %>/assets/scss/{,*/}*.scss'],
tasks: ['sass', 'autoprefixer']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= config.dist %>/{,*/}*.html',
'<%= config.dist %>/assets/{,*/}*.css',
'<%= config.dist %>/assets/{,*/}*.js',
'<%= config.dist %>/assets/{,*/}*.{png,jpg,jpeg,gif,webp,svg,ico}'
]
}
},
//Grunt server settings
connect: {
options: {
port: 9000,
livereload: 35729,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
'<%= config.dist %>'
]
}
}
},
assemble: {
options: {
flatten: true,
assets: '<%= config.dist %>/assets',
data: '<%= config.src %>/data/*.{json,yml}',
layout: '<%= config.src %>/templates/layouts/default.hbs',
partials: '<%= config.src %>/templates/partials/*.hbs'
},
site: {
options: {
layout: '<%= config.src %>/templates/layouts/default.hbs'
},
src: ['<%= config.src %>/templates/site/*.hbs'],
dest: '<%= config.dist %>'
}
},
// Before generating any new files,
// remove any previously-created files.
clean: [
'<%= config.dist %>/**/*.{html,xml}'
],
//Compile SCSS
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'<%= config.dist %>/assets/style.min.css': '<%= config.src %>/assets/scss/style.scss'
}
}
},
//Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 2 version', 'ie 8', 'ie 9'],
map: true
},
no_dest: {
src: '<%= config.dist %>/assets/style.min.css'
},
},
//JAVASCRIPT
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'<%= config.src %>/assets/scripts/custom/{,*/}*.js',
'!<%= config.src %>/assets/scripts/vendor/*'
]
},
//Stick everything together, you'll need to specify JS files in the correct order here.
concat: {
dist: {
src: [
'<%= config.src %>/assets/scripts/vendor/jquery/dist/jquery.js',
'<%= config.src %>/assets/scripts/vendor/handlebars/handlebars.js',
'<%= config.src %>/assets/scripts/custom/**/*.js'
],
dest: '<%= config.dist %>/assets/scripts.js',
},
},
//Uglify
uglify: {
build: {
src: '<%= config.dist %>/assets/scripts.js',
dest: '<%= config.dist %>/assets/scripts.min.js'
},
modernizer: {
src: '<%= config.src %>/assets/scripts/vendor/modernizer/modernizr.js',
dest: '<%= config.dist %>/assets/modernizr.min.js'
}
},
//IMAGES
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: '<%= config.src %>/assets/images',
src: ['**/*.{png,jpg,jpeg,gif,webp,svg,ico}'],
dest: '<%= config.dist %>/images'
}]
}
}
});
grunt.registerTask('server', [
'clean',
'assemble',
'sass',
'autoprefixer',
'jshint',
'concat',
'uglify',
'imagemin',
'connect:livereload',
'watch'
]);
grunt.registerTask('build', [
'clean',
'assemble',
'sass',
'autoprefixer',
'jshint',
'concat',
'uglify',
'imagemin'
]);
grunt.registerTask('default', [
'build'
]);
};