First-class e-mail support

This is the ratchet, probably totally brittle way I find my app’s css to later be inlined in my e-mail html:

// server/sendEmailExample.js

var fs = Npm.require('fs');
...
var cssName = _.find(Object.keys(WebAppInternals.staticFiles), function (fileName) { return /.css$/.test(fileName) });
var cssPath = WebAppInternals.staticFiles[cssName].absolutePath;
var css = fs.readFileSync(cssPath);
...
var html = SSR.render(...);
var htmlWithInlineCss = juice(html, {extraCss: css});

Has anyone come across a better way to access the app’s css?

11 Likes

This is actually the most amazing thing I’ve ever seen.

Whoa! Dude! Seriously! This is amazing!

Yep. That’s up at the top of the list of “Cool things I’ve seen today”.

Very elegant! :smile: