Grunt is a task runner for front-end development. ThinkUp uses it for a few things.
Below you’ll find instructions on installing Grunt and using it for these tasks.
In order to compile JS and CSS, you need to have NodeJS installed on your machine. If you’re compiling HTML emails, you’ll need Ruby too. This has been tested on a Mac, but should work on any machine that supports Ruby and Node. We’ll cover installation below, but these are the required packages.
gem install hpricot premailer
. (You
can skip this step if you’re not compiling HTML emails).npm install
. This should install all of the NodeJS
modules we use in ThinkUp.npm install -g grunt-cli
.HTML rendering in email clients is pretty poor, but it does pretty well if you use inline styles. Since it’s a pain to write your CSS rules inline, we don’t; we use software.
The precompiled HTML email template for our insights lives at
extras/dev/precompiledtemplates/email/_email.insights_html.tpl
and is written to
webapp/plugins/insightsgenerator/view/_email.insights_html.tpl
.
Once you’ve gotten through the installation, using the inliner is incredibly easy.
grunt html_email
. You can optionally run grunt watch
and
leave the process open as you work on your template. Everytime you save the source template, it will recompile.The key thing to understand is that ThinkUp CSS development is done in LESS, then compiled to CSS. This means working directly with ThinkUp CSS files means your changes might be overwritten. The same is true for CoffeeScript and Javascript.
Our LESS files live in extras/dev/assets/less/
and get compiled to webapp/assets/css/
. Similarly, our
Coffeescript files live in extras/dev/assets/coffee/
and get compiled to webapp/assets/js/
.
Just like inlining CSS for emails, whenever you save a LESS or Coffeescript file, you can run grunt less
or
grunt coffee
. You can also run grunt watch
and it will compile the files automatically on save.