forked from womenhackfornonprofits/whfnp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
205 lines (197 loc) · 6.56 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
202
203
204
205
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-aws-s3');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-prettify');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-shell');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//s3settings: grunt.file.readJSON('s3settingsprod.json'), //-- READS THE PROD CREDENTIALS TO DEPLOY TO PROD ---//
s3settings: grunt.file.readJSON('s3settings.json'),
//------- AWS -------//
aws_s3: {
options: {
accessKeyId: '<%= s3settings.key %>',
secretAccessKey: '<%= s3settings.secret %>',
region: '<%= s3settings.region %>',
uploadConcurrency: 5,
downloadConcurrency: 5
},
img: {
options: {
bucket: '<%= s3settings.bucket %>',
differential: true // Only uploads the files that have changed
},
files: [
{expand: true, cwd: 'deploy/img/', src: ['**/*.{png,jpg,jpeg,JPG}'], dest: 'img/', params: {CacheControl: 'max-age=31536000, public'}},
]
},
svg: {
options: {
bucket: '<%= s3settings.bucket %>',
differential: true // Only uploads the files that have changed
},
files: [
{expand: true, cwd: 'deploy/img/', src: ['**/*.svg'], dest: 'img/', params: {CacheControl: 'max-age=31536000, public', ContentEncoding: 'gzip'}},
]
},
html: {
options: {
bucket: '<%= s3settings.bucket %>',
differential: true // Only uploads the files that have changed
},
files: [
//{expand: true, cwd: 'deploy/', src: ['*.html'], dest: '', params: {CacheControl: 'max-age=31536000, public', ContentEncoding: 'gzip'}},
{expand: true, cwd: 'deploy/', src: ['*.html'], dest: '', params: {CacheControl: 'max-age=31536000, public'}},
]
},
css: {
options: {
bucket: '<%= s3settings.bucket %>',
differential: true // Only uploads the files that have changed
},
files: [
//{expand: true, cwd: 'deploy/css/', src: ['**'], dest: '', params: {CacheControl: 'max-age=31536000, public', ContentEncoding: 'gzip'}},
{expand: true, cwd: 'deploy/css/', src: ['**'], dest: 'css/', params: {CacheControl: 'max-age=31536000, public'}},
]
},
download: {
options: {
bucket: '<%= s3settings.bucket %>',
},
files: [
{dest: '/', cwd: 'backup/', action: 'download'},
]
},
},
//------- CSS Minify -------//
cssmin: {
combine: {
files: [
{expand: true, cwd: 'src', src: ['**/*.css'], dest: 'deploy/'},
]
}
},
//------- HTML Minify -------//
htmlmin: { // Task
dist: { // Target
options: { // Target options
removeComments: true,
collapseWhitespace: true,
},
files: [
{expand: true, cwd: 'src/_site', src: ['**/*.html'], dest: 'deploy/'},
]
}
},
//------- Copy -------//
copy: {
main: {
files: [
// includes files within path
{expand: true, cwd: 'src/', src: ['css'], dest: 'deploy/', filter: 'isFile'},
]
},
img: {
files: [
{expand: true, cwd: 'src/img', src: ['*.{png,jpg,jpeg,svg}'], dest: 'deploy/img/', filter: 'isFile'},
]
}
},
//------- SASS -------//
sass: {
dev: {
options: {
style: 'expanded',
loadPath: 'node_modules/bootstrap-sass/assets/stylesheets'
},
},
dist: {
options: {
style: 'compressed',
loadPath: 'node_modules/bootstrap-sass/assets/stylesheets'
},
files: {
'src/css/screen.css': 'src/sass/screen.scss'
}
}
},
//------- Watch SASS -> CSS -------//
watch: {
sass: {
files: 'src/sass/**/*.scss',
tasks: ['sass:dev']
}
},
//------- IMAGE min -------//
imagemin: { // Task
dynamic: { // Another target
files: [{
expand: true, // Enable dynamic expansion
cwd: 'src/img/', // Src matches are relative to this path
src: ['**/*.{png,jpg,svg,jpeg}'], // Actual patterns to match
dest: 'deploy/img/' // Destination path prefix
}]
}
},
//-------- Prettify HTML ------//
prettify: {
options: {
// Task-specific options go here.
},
html: {
// Target-specific file lists and/or options go here.
expand: true,
cwd: 'src/',
ext: '.html',
src: ['*.html'],
dest: 'src/'
}
},
//-------- Compress HTML ------//
compress: {
main: {
options: {
mode: 'gzip'
},
files: [
{expand: true, src: ['deploy/*.html'], dest: '', ext: '.html'},
{expand: true, src: ['deploy/css/screen.css'], dest: '', ext: '.css'},
]
}
},
shell: {
jekyllBuild: {
command: 'jekyll build --source src --destination src/_site'
},
jekyllServe: {
command: 'jekyll serve --source src --destination src/_site'
}
},
concurrent: {
serve: [
'sass',
'watch',
'shell:jekyllServe'
],
options: {
logConcurrentOutput: true
}
},
});
grunt.registerTask('serve', ['concurrent:serve']);
/** DEPLOY task deployes all changes, check individual tasks above to see what they do **/
grunt.registerTask('deploy', ['default', 'imagemin', 'aws_s3:css','aws_s3:html', 'aws_s3:img', 'aws_s3:svg']);
/** IMG task processess ALL images from src to deploy and optimizes them **/
grunt.registerTask('img', ['imagemin', 'copy:img']);
/** DEFAULT task that compiles, minifies and copies relevant files,
images are not copied everytime as the current once on site are gzipped.
Images are not an asset that changes often so there is a secial task to copy**/
grunt.registerTask('default', ['sass:dist', 'copy:main', 'cssmin', 'htmlmin', 'serve']);
};