Skip to content

Commit

Permalink
default sass implementation option
Browse files Browse the repository at this point in the history
  • Loading branch information
jbailey4 committed Sep 4, 2018
1 parent a8fbf2e commit 2ad8468
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
[![Ember Observer Score](http://emberobserver.com/badges/ember-cli-sass.svg)](http://emberobserver.com/addons/ember-cli-sass)
[![Dependency Status](https://david-dm.org/aexmachina/ember-cli-sass.svg)](https://david-dm.org/aexmachina/ember-cli-sass)

ember-cli-sass uses [Dart Sass][] or [LibSass][] to preprocess your ember-cli app's files and provides support for source maps and include paths. It provides support for the common use case for Ember.js projects:
ember-cli-sass uses [Dart Sass][] to preprocess your ember-cli app's files and provides support for source maps and include paths. It provides support for the common use case for Ember.js projects:

[Dart Sass]: https://sass-lang.com/dart-sass
[LibSass]: https://sass-lang.com/libsass

- Source maps by default in development
- Support for [`outputPaths` configuration](http://ember-cli.com/user-guide/#configuring-output-paths)
Expand All @@ -19,7 +18,6 @@ ember-cli-sass uses [Dart Sass][] or [LibSass][] to preprocess your ember-cli ap

```
ember install ember-cli-sass
npm install --save-dev sass # or node-sass to use LibSass
```

### Addon Development
Expand All @@ -30,18 +28,18 @@ If you want to use ember-cli-sass in an addon and you want to distribute the com
npm install --save ember-cli-sass sass
```

## Usage
## Using a different Sass implementation

To use this addon, you must pass a Sass implementation to the `sassOptions`
By default this addon uses a distribution of Dart Sass that is compiled to pure JavaScript, if you would like to use an alternative implementation (e.g. [`node-sass`](https://github.com/sass/node-sass)), you must pass a Sass implementation to the `sassOptions`
config property in `ember-cli-build.js` (or in `Brocfile.js` if you are using an
Ember CLI version older than 1.13):

```javascript
var sass = require('sass');
var nodeSass = require('node-sass');

var app = new EmberApp({
sassOptions: {
implementation: sass
implementation: nodeSass
}
});
```
Expand Down
15 changes: 11 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ SASSPlugin.prototype.toTree = function(tree, inputPath, outputPath, inputOptions
}

if (!options.implementation) {
var error = new Error(
'sassOptions must have an implementation option. For example:\n' +
' sassOptions: {implementation: require("sass")}');
error.type = 'Sass Plugin Error';
try {
options.implementation = require('sass');
} catch () {
var error = new Error(
'Could not find the default SASS implementation. Run the default blueprint:\n' +
' ember g ember-cli-sass\n' +
'Or install an implementation such as "node-sass" and add an implementation option. For example:\n' +
' sassOptions: {implementation: require("node-sass")}');
error.type = 'Sass Plugin Error';

throw error;
}
}

var SassCompiler = SassCompilerFactory(options.implementation);
Expand Down

0 comments on commit 2ad8468

Please sign in to comment.