forked from leemunroe/grunt-email-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
111 lines (97 loc) · 3.23 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Takes your scss files and compiles them to css
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'src/css/main.css': 'src/css/scss/main.scss',
'src/css/responsive.css': 'src/css/scss/responsive.scss'
}
}
},
// Assembles your email content with html layout
assemble: {
options: {
layoutdir: 'src/layouts',
flatten: true
},
pages: {
src: ['src/emails/*.hbs'],
dest: 'dist/'
}
},
// Inlines your css
premailer: {
simple: {
options: {
removeComments: true
},
files: [{
expand: true,
src: ['dist/*.html'],
dest: ''
}]
}
},
// Watches for changes to css or email templates then runs grunt tasks
watch: {
files: ['src/css/scss/*','src/emails/*','src/layouts/*'],
tasks: ['default']
},
// Use Mailgun option if you want to email the design to your inbox or to something like Litmus
mailgun: {
mailer: {
options: {
key: 'MAILGUN_KEY', // Enter your Mailgun API key here
sender: '[email protected]', // Change this
recipient: '[email protected]', // Change this
subject: 'This is a test email'
},
src: ['dist/'+grunt.option('template')]
}
},
// Use Rackspace Cloud Files if you're using images in your email
cloudfiles: {
prod: {
'user': 'Rackspace Cloud Username', // Change this
'key': 'Rackspace Cloud API Key', // Change this
'region': 'ORD', // Might need to change this
'upload': [{
'container': 'Files Container Name', // Change this
'src': 'src/img/*',
'dest': '/',
'stripcomponents': 0
}]
}
},
// CDN will replace local paths with your Cloud CDN path
cdn: {
options: {
cdn: 'Rackspace Cloud CDN URI', // Change this
flatten: true,
supportedTypes: 'html'
},
dist: {
src: ['./dist/*.html']
}
}
});
// Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-mailgun');
grunt.loadNpmTasks('grunt-premailer');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-cloudfiles');
grunt.loadNpmTasks('grunt-cdn');
// Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['sass','assemble','premailer']);
// Use grunt send if you want to actually send the email to your inbox
grunt.registerTask('send', ['mailgun']);
// Upload images to our CDN on Rackspace Cloud Files
grunt.registerTask('cdnify', ['default','cloudfiles','cdn']);
};