-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
142 lines (138 loc) · 4.26 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
module.exports = function (grunt) {
grunt.initConfig({
// clean dirs
clean: ['src/assets/css/', 'dist/'],
// compile sass files
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'src/assets/css/main.css': 'src/assets/sass/main.scss'
}
}
},
// minify images
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'assets/img/',
src: ['*.{png,jpg,gif}'],
dest: '/build/assets/img/'
}]
}
},
// assemble static pages
assemble: {
options: {
data: 'src/data/*.yml',
layoutdir: 'src/layouts/',
layout: 'default.hbs',
partials: 'src/partials/*.hbs',
assets: 'src/assets/',
flatten: true
},
pages: {
src: ['src/emails/*.hbs'],
dest: 'dist/'
}
},
// inline css
premailer: {
html: {
options: {
removeComments: true
},
files: [{
expand: true,
src: ['dist/*.html'],
dest: ''
}]
},
txt: {
options: {
mode: 'txt'
},
files: [{
expand: true,
src: ['dist/*.html'],
dest: '',
ext: '.txt'
}]
}
},
// static server
connect: {
server: {
options: {
port: 8080,
base: 'dist'
}
}
},
// watch for changes
watch: {
statp: {
files: ['assets/img/*', 'src/assets/sass/*', 'src/emails/*', 'src/layouts/*', 'src/partials/*'],
tasks: ['build'],
options: {
livereload: true
}
}
},
mailgun: {
mailer: {
options: {
key: 'MAILGUN_KEY', // Enter your Mailgun key
sender: grunt.option('from'), //SENDER_MAIL
recipient: grunt.option('to'), //RECEPIENT_MAIL
subject: grunt.option('subject') //MESSAGE_SUBJECT
},
src: ['dist/'+grunt.option('template')]
}
},
// Amazon S3 and Cloudfront
s3: {
options: {
accessKeyId: 'AWS_KEY', // change with your AWS key
secretAccessKey: 'AWS_SECRET_KEY', // change with your AWS secret key
bucket: 'NAME_OF_BUCKET' // change with your AWS bucket name
},
build: {
cwd: 'src/assets/img/build',
src: '**'
}
},
// cdnfiy assets paths
cdnify: {
someTarget: {
options: {
base: 'URL_TO_PREPEND' // the url to append eg http://cdn.site.com
},
files: [{
expand: true,
cwd: 'dist/',
src: '**/*.html',
dest: 'dist'
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-premailer');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-aws');
grunt.loadNpmTasks('grunt-cdnify');
grunt.loadNpmTasks('grunt-mailgun');
grunt.registerTask('build', ['clean','sass','assemble','premailer','newer:imagemin']);
grunt.registerTask('dev', ['build', 'connect', 'watch']);
grunt.registerTask('cdnifyd', ['build','s3','cdnify']);
grunt.registerTask('send', ['mailgun']);
};