- Notifications
You must be signed in to change notification settings - Fork333
A Grunt workflow for designing and testing responsive HTML email templates with SCSS.
License
leemunroe/grunt-email-workflow
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- update packages and dependencies for current node versions: nvm not needed
- remove obsolete tasks and packages
Designing and testing emails is a pain. HTML tables, inline CSS, various devices and clients to test, and varying support for the latest web standards.
This Grunt task helps simplify things.
- Compiles your SCSS to CSS
- Builds your HTML email templates
- Inlines your CSS
You may already have these installed on your system. If not, you'll have to install them.
- Node.js -Install Node.js
- Grunt-cli and Grunt (
npm install grunt-cli -g)
If you haven't usedGrunt before check out Chris Coyier's post ongetting started with Grunt.
Clone this repo, cd to the directory, runnpm install to install the necessary packages.
cd grunt-email-workflownpm installThe very first installation may take a while. Please wait patiently until completion.
Rungrunt build and check out your/dist folder to see your compiled and inlined email templates.Rungrunt serve, a new live-reload browser tab will open. Happy coding :)
If you're usingMailgun and/orAmazon S3 create asecrets.json file in your project root as outlined below under "Sensitive Information".
If you don't use or need these servicesit's ok to skip this step.
We encourage younot to store sensitive data in your git repository. If you must, please look intogit-encrypt or some other method of encrypting your configuration secrets.
- Create a file
secrets.jsonin your project root. - Paste the following sample code in
secrets.jsonand enter the appropriate credentials for the services you want to connect with.
{"mailgun": {"api_key":"YOUR MG PRIVATE API KEY","domain":"YOURDOMAIN.COM","sender":"E.G. POSTMASTER@YOURDOMAIN.COM","recipient":"WHO YOU WANT TO SEND THE EMAIL TO" },"s3": {"key":"AMAZON S3 KEY","secret":"AMAZON S3 SECRET","region":"AMAZON S3 REGION","bucketname":"AMAZON S3 BUCKET NAME","bucketdir":"AMAZON S3 BUCKET SUBDIRECTORY (optional)","bucketuri":"AMAZON S3 PATH (ex: https://s3.amazonaws.com/)" }}After this you should be good to go. Rungrunt build and your email templates should appear automagically in a/dist folder.
This project usesSCSS. You don't need to touch the .css files, these are compiled automatically.
For changes to CSS, modify the.scss files.
Media queries and responsive styles are in a separate style sheet so that they don't get inlined. Note that only a few clients support media queries e.g. iOS Mail app.
Handlebars and Assemble are used for templating.
/layouts contains the standard header/footer HTML wrapper markup. You most likely will only need one layout template, but you can have as many as you like.
/emails is where your email content will go. To start you off I've included example transactional emails based on mysimple HTML email template.
/data containsoptional .yml or .json data files that can be used in your templates. It's a good way to store commonly used strings and variables. See/data/default.yml and/partials/follow_lee.hbs for an example.
/partials containsoptional .hbs files that can be thought of like includes. To use a partial, for example/partials/follow_lee.hbs you would use the following code in your emails template:
{{>follow_lee}}
/partials/components containsoptional .hbs files that can help generate your markup. Each component will typically have a corresponding Sass file insrc/css/sass/<component_name>.scss. To use a component, for example/partials/components/button.hbs you would use the following code in your emails template.(note: You can use single -or- double quotes for attributes)
{{>buttontype="primary"align="center"url="LINK GOES HERE"title="ANCHOR TEXT GOES HERE"}}
In terminal, rungrunt build. This will:
- Compile your SCSS to CSS
- Generate your email layout and content
- Inline your CSS
See the output HTML in thedist folder. Open them and preview it the browser.
Alternatively rungrunt serve. This will check for any changes you make to your .scss and .hbs templates, automatically run the tasks, and serve you a preview in the browser onhttp://localhost:4000. Saves you having to run grunt every time you make a change.
In terminal, rungrunt serve.
- This will run the default tasks
grunt+ thewatchtask will be initiated - A preview UI will automagically open onhttp://localhost:4000 and you can review your templates
- Go about your business editing templates and see your template changes live-reload
- NOTE: The express server stops working when the
watchtask is not running

I've added a few templates here to help you get started.
- For more transactional email templates check outHTML Email templates
- Things I've learned about sending email
- Things I've learned about building email templates
- Things I've learned about responsive email
- Prefer Gulp? Daryll Doyle has created aGulp email creator
About
A Grunt workflow for designing and testing responsive HTML email templates with SCSS.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.