Skip to content

Commit 39c746f

Browse files
committed
feat(workflow): update packages, make nvm obsolete
1 parent 290555e commit 39c746f

14 files changed

+9168
-39237
lines changed

.nvmrc

-1
This file was deleted.

Gruntfile.js

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
module.exports = function(grunt) {
1+
(function() {
2+
const path = require('path'),
3+
folders = {
4+
app: 'app',
5+
dist: 'dist',
6+
tmp: '.tmp'
7+
};
28

3-
require('load-grunt-config')(grunt, {
9+
module.exports = function(grunt) {
10+
var path = require('path');
411

5-
// Pass data to tasks
6-
data: {
7-
8-
// Re-usable filesystem path variables
9-
paths: {
10-
src: 'src',
11-
src_img: 'src/img',
12-
dist: 'dist',
13-
dist_img: 'dist/img',
14-
preview: 'preview'
15-
},
16-
17-
// secrets.json is ignored in git because it contains sensitive data
18-
// See the README for configuration settings
19-
secrets: grunt.file.readJSON('secrets.json')
20-
21-
}
22-
});
23-
};
12+
require('load-grunt-config')(grunt, {
13+
configPath: [
14+
path.join(process.cwd(), 'grunt'),
15+
],
16+
init: true,
17+
data: {
18+
folders: folders,
19+
paths: {
20+
src: 'src',
21+
src_img: 'src/img',
22+
dist: 'dist',
23+
dist_img: 'dist/img',
24+
preview: 'preview'
25+
},
26+
}
27+
});
28+
};
29+
})();

license.txt LICENSE

File renamed without changes.

README.md

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Grunt Email Design Workflow
2+
based on [github.com/leemunroe](https://github.com/leemunroe/grunt-email-workflow)
3+
4+
## Changelog
5+
6+
### v0.2.0 - 09/01/2024
7+
8+
* update packages and dependencies for current node versions: nvm not needed
9+
* disable third-party connections (see [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation))
10+
11+
## Purpose
12+
13+
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.
14+
15+
This Grunt task helps simplify things.
16+
17+
1. Compiles your SCSS to CSS
18+
2. Builds your HTML email templates
19+
3. Inlines your CSS
20+
21+
## Requirements
22+
23+
You may already have these installed on your system. If not, you'll have to install them.
24+
25+
* Node.js - [Install Node.js](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)
26+
* Grunt-cli and Grunt (`npm install grunt-cli -g`)
27+
* (optional) [Litmus](https://litmus.com) - Tests the email across all clients/browsers/devices
28+
29+
## Getting started
30+
31+
If you haven't used [Grunt](http://gruntjs.com/) before check out Chris Coyier's post on [getting started with Grunt](http://24ways.org/2013/grunt-is-not-weird-and-hard/).
32+
33+
#### 1. Setup
34+
35+
Clone this repo, cd to the directory, run `npm install` to install the necessary packages.
36+
37+
```sh
38+
cd grunt-email-workflow
39+
npm install
40+
```
41+
42+
#### 2. Run Grunt
43+
44+
Run `grunt build` and check out your `/dist` folder to see your compiled and inlined email templates.
45+
46+
Run `grunt serve`, a new live-reload browser tab will open. Happy coding :)
47+
48+
## How it works
49+
50+
### CSS
51+
52+
This project uses [SCSS](http://sass-lang.com/). You don't need to touch the .css files, these are compiled automatically.
53+
54+
For changes to CSS, modify the `.scss` files.
55+
56+
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.
57+
58+
### Email templates and content
59+
60+
Handlebars and Assemble are used for templating.
61+
62+
`/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.
63+
64+
`/emails` is where your email content will go. To start you off I've included example transactional emails based on my [simple HTML email template](https://github.com/leemunroe/html-email-template).
65+
66+
`/data` contains _optional_ .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.
67+
68+
`/partials` contains _optional_ .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:
69+
70+
```hbs
71+
{{> follow_lee }}
72+
```
73+
74+
`/partials/components` contains _optional_ .hbs files that can help generate your markup. Each component will typically have a corresponding Sass file in `src/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)_
75+
76+
```hbs
77+
{{> button type="primary" align="center" url="LINK GOES HERE" title="ANCHOR TEXT GOES HERE" }}
78+
```
79+
80+
### Generate your email templates
81+
82+
In terminal, run `grunt build`. This will:
83+
84+
* Compile your SCSS to CSS
85+
* Generate your email layout and content
86+
* Inline your CSS
87+
88+
See the output HTML in the `dist` folder. Open them and preview it the browser.
89+
90+
Alternatively run `grunt 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 on http://localhost:4000. Saves you having to run grunt every time you make a change.
91+
92+
### Browser-based previews
93+
94+
In terminal, run `grunt serve`.
95+
96+
* This will run the default tasks `grunt` + the `watch` task will be initiated
97+
* A preview UI will automagically open on [http://localhost:4000](http://localhost:4000) and you can review your templates
98+
* Go about your business editing templates and see your template changes live-reload
99+
* __NOTE:__ The express server stops working when the `watch` task is not running
100+
101+
102+
### Sample email templates
103+
104+
I've added a few templates here to help you get started.
105+
106+
* [Simple transactional email template](http://leemunroe.github.io/grunt-email-workflow/dist/transaction.html)
107+
* [Branded email via CDN](http://leemunroe.github.io/grunt-email-workflow/dist/branded.html)
108+
* [Email with components](http://leemunroe.github.io/grunt-email-workflow/dist/components.html)
109+
110+
### More resources
111+
112+
* For more transactional email templates check out [HTML Email templates](https://htmlemail.io)
113+
* [Things I've learned about sending email](http://www.leemunroe.com/sending-email-designers-developers/)
114+
* [Things I've learned about building email templates](http://www.leemunroe.com/building-html-email/)
115+
* [Things I've learned about responsive email](https://www.leemunroe.com/responsive-email-design/)
116+
* Prefer Gulp? Daryll Doyle has created a [Gulp email creator](https://github.com/darylldoyle/Gulp-Email-Creator)

grunt/aliases.yaml

+12-34
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
# Where we tell Grunt what to do when we type "grunt" into the terminal
2-
# $ grunt
31
default:
4-
- 'clean'
5-
- 'sass:dist'
6-
- 'assemble'
7-
- 'juice'
8-
- 'imagemin'
9-
- 'replace:src_images'
2+
- serve
103

11-
# Use grunt send if you want to actually send the email to your inbox
12-
# $ grunt send --template=transaction.html
13-
send:
14-
- 'mailgun'
4+
build:
5+
- clean
6+
- sass:dist
7+
- assemble
8+
- juice
159

16-
# Upload images to your CDN on Rackspace Cloud Files
17-
# $ grunt rsupload
18-
rsupload:
19-
- 'default'
20-
- 'cloudfiles'
21-
- 'cdn:cloudfiles'
22-
23-
# Upload image files to Amazon S3
24-
# $ grunt s3upload
25-
s3upload:
26-
- 'default'
27-
- 'aws_s3:prod'
28-
- 'cdn:aws_s3'
29-
30-
# Launch the express server and start watching
31-
# $ grunt serve
3210
serve:
33-
- 'default'
34-
- 'sass:preview'
35-
- 'autoprefixer:preview'
36-
- 'express'
37-
- 'open'
38-
- 'watch'
11+
- build
12+
- sass:preview
13+
- autoprefixer:preview
14+
- express:server
15+
- open
16+
- watch

grunt/express.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
// Browser-based preview task
21
module.exports = {
32
server: {
43
options: {
4+
cmd: process.argv[0],
5+
background: true,
6+
delay: 1000,
7+
output: '.+',
58
port: 4000,
6-
hostname: '127.0.0.1',
9+
script: './server.js',
10+
debug: true,
711
bases: ['<%= paths.dist %>', '<%= paths.preview %>', '<%= paths.src %>'],
8-
server: './server.js',
9-
livereload: true
12+
livereload: true,
13+
spawn: false,
1014
}
1115
}
12-
}
16+
};

grunt/juice.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Inlines your CSS
22
module.exports = {
3-
your_target: {
3+
dist: {
44
options: {
55
preserveMediaQueries: true,
66
applyAttributesTableElements: true,

grunt/watch.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
module.exports = {
33
emails: {
44
files: ['<%= paths.src %>/css/scss/*/**','<%= paths.src %>/emails/*','<%= paths.src %>/layouts/*','<%= paths.src %>/partials/**/*','<%= paths.src %>/data/*'],
5-
tasks: ['default']
5+
tasks: ['build'],
6+
options: {
7+
livereload: true
8+
}
69
},
710
preview_dist: {
811
files: ['./dist/*'],

0 commit comments

Comments
 (0)