Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Make node-sass opt in. #35

Merged
merged 4 commits into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ iron:[email protected]
[email protected]_2
[email protected]
[email protected]
lookback:[email protected].5
lookback:[email protected].6
[email protected]
meteorhacks:[email protected]
[email protected]
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Usually, building HTML emails yourself is tedious. On top of that, add the need

- **Server side rendering** with the [Meteor SSR](https://github.com/meteorhacks/meteor-ssr/) package. Use Blaze features and helpers like on the client.
- **CSS inlining** with [Juice](http://npmjs.org/package/juice). No extra build step.
- **SCSS support** using `node-sass` (opt-in).
- **Preview and debug** emails in development mode in your browser when developing.
- **Layouts** for re-using markup.

Expand All @@ -25,6 +26,14 @@ meteor add lookback:emails

A `Mailer` global will exported on the *server*.

**Notice.** If you want SCSS support, be sure to add the `[meteor-node-sass](https://github.com/chrisbutler/meteor-node-sass)` package to your app:

```
meteor add chrisbutler:node-sass
```

`lookback:emails` will automatically detect `node-sass` being available, and will be able to compile `.scss` files.

## Sample app

There is a sample application in this repo, in the `example` directory. Boot it up, and preview an email with:
Expand Down Expand Up @@ -410,6 +419,7 @@ Why not try [`meteor-logger`](https://github.com/lookback/meteor-logger)? :)

## Version history

- `0.5.0` - Remove `node-sass` as hard dependency. SCSS support is now opt-in, by adding `chrisbutler:node-sass` to your app.
- `0.4.6` - Fix paths on Windows in development mode.
- `0.4.5`
- CSS and SCSS is now compiled and inlined at runtime, in order to inline CSS for the rendered content. If CSS only was inlined at compile time, the dynamic content wouldn't get any styling.
Expand Down
1 change: 1 addition & 0 deletions example/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ meteor-platform
autopublish
insecure
lookback:emails
chrisbutler:[email protected]
2 changes: 1 addition & 1 deletion example/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
lookback:emails@0.4.5
lookback:emails@0.5.0
[email protected]
[email protected]
meteorhacks:[email protected]
Expand Down
4 changes: 3 additions & 1 deletion example/private/layout.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$color: #333;

body, p {
font-family: sans-serif;
color: #333;
color: $color;
text-align: center;
}
5 changes: 3 additions & 2 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ var where = 'server';
Package.describe({
name: 'lookback:emails',
summary: 'Send HTML emails with server side Blaze templates. Preview and debug in the browser.',
version: '0.4.6',
version: '0.5.0',
git: 'https://github.com/lookback/meteor-emails.git'
});

Package.onUse(function(api) {

api.versionsFrom('1.0.4');

api.use('chrisbutler:[email protected]', where, { weak: true });

api.use([
'check',
'underscore',
'coffeescript',
'email',
'sacha:[email protected]',
'chrisbutler:[email protected]',
'iron:[email protected]',
'meteorhacks:[email protected]'
], where);
Expand Down
6 changes: 6 additions & 0 deletions utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ Utils =

# Take a path to a SCSS file and compiles it to CSS with `node-sass`.
toCSS: (scss) ->
if !Package['chrisbutler:node-sass']
Utils.Logger.warn 'Sass support is opt-in since lookback:[email protected]. Please add chrisbutler:node-sass from Atmosphere and try again.', TAG
# Return file contents.
return Utils.readFile(scss)

file = path.join(ROOT, scss)
sass = Package['chrisbutler:node-sass'].sass

try
return sass.renderSync(file: file, sourceMap: false).css.toString()
Expand Down