Access css from the server

What’s the best way to access css from the server (for sending html emails) ? Is there a way to get the link of the merge stylesheet and request it from the client. I guess that’d be simpler than making all the style file accessible from the server and client which would be confusing.

You could put your CSS in the public directory, and reference it in your app using kadira:dochead. That way your email could also load it…?

Thanks. I’m using the less package, so not really sure how the css got compiled and where it goes. I’ll look into it

Ah yeah, that makes it a bit more complicated because meteor does the pre-processing of the LESS into CSS for you with that package. That won’t work in the public dir without some hackery.

Are you sending emails from the client-side? That’s a big no-no. A user could easily open the developer console and start sending spam emails through your app. If I misunderstood, just ignore this. Otherwise, don’t do this. Never.

Also, HTML emails should not reference CSS files as external stylesheets; does not work with a majority of email clients (only Apple Mail supports it apparently). Embed the CSS instead. That’s the way to go.

No I’m sending the emails from the server. I want to reuse component and style defined on the client. I’m using the npm juice package to take a css file and merge it with some html to get html with inline css that is then good to go. It’s fine to pass the entire app’s css to juice because it only keeps the bits that applied to the html sent in the email.

My issue is that I’m defining a bunch of less files that meteor nicely compile into one css file for the client, but I can’t access it from the server. At the moment, I’m manually copying this compile css into a file that is in /server, but that’s not very nice…

I’m independently having issues with loading the juice package in production (probably related to Meteor 1.3 issues with loading npm packages that load files at runtime using fs) so I’ll share this imperfect solution when I’ve solved that bit out.

ahh thanks I didn’t know this, never really built any fancy emails into apps :slight_smile: