forked from agrc/gis.utah.gov
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntFile.js
More file actions
139 lines (135 loc) · 4.41 KB
/
GruntFile.js
File metadata and controls
139 lines (135 loc) · 4.41 KB
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
var repoName = 'website';
module.exports = function (grunt) {
'use strict';
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
htmlmin: {
main: {
options: {
removeComments: true
// collapseWhitespace: true,
// conservativeCollapse: true
// removeEmptyAttributes: true,
// removeRedundantAttributes: true,
// collapseInlineTagWhitespace: true
},
files: [{
expand: true,
src: ['_site/**/*.html', '!_site/node_modules/**/*']
}]
}
},
imagemin: {
images: {
options: {
optimizationLevel: 3
},
files: [{
expand: true, // Enable dynamic expansion
cwd: 'images/', // Src matches are relative to this path
src: ['**/*.{png,jpg,jpeg,gif}'], // Actual patterns to match
dest: 'images/' // Destination path prefix
}]
},
downloads: {
options: {
optimizationLevel: 3
},
files: [{
expand: true, // Enable dynamic expansion
cwd: 'downloads/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'downloads/' // Destination path prefix
}]
}
},
jekyll: {
main: {
options: {
port: 4444,
serve: true,
auto: true,
drafts: true,
incremental: true
}
}
},
replace: {
user: {
options: {
patterns: [{
match: 'sass',
replacement: 'nested'
}]
},
src: '_config.yml_',
dest: '_config.yml'
},
repo: {
options: {
patterns: [{
match: 'sass',
replacement: 'nested'
}, {
match: /\"\/bower_component/g,
replacement: '"/' + repoName + '/bower_component'
}]
},
files: [
{src: '_config.yml_', dest: '_config.yml'},
{src: '_sass/vars.scss', dest: '_sass/vars.scss'}
]
},
sass: {
options: {
patterns: [{
match: 'sass',
replacement: 'compressed'
}]
},
src: '_config.yml_',
dest: '_config.yml'
}
},
uglify: {
list: {
src: ['bower_components/list.js/dist/list.min.js', 'js/source/list.js'],
dest: 'js/dist/list.min.js'
},
search: {
src: ['bower_components/mustache.js/mustache.min.js', 'js/source/search.js'],
dest: 'js/dist/search.min.js'
}
}
});
// Dependencies
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-replace');
// use this task if you are running this from user.github.io or localhost:4444
grunt.registerTask('default', [
'newer:imagemin',
'replace:user',
'uglify',
'jekyll:main'
]);
// use this task if you are running this from user.github.io/repository
// set repoName at the top of the file to match your repository
grunt.registerTask('repo', [
'newer:imagemin',
'replace:repo',
'uglify',
'jekyll:main'
]);
// run this before publishing to crunch all the stuff
grunt.registerTask('compress', [
'newer:imagemin',
'replace:sass',
'uglify'
])
};