Skip to content

Commit

Permalink
Add support for new targets feature in ember-cli.
Browse files Browse the repository at this point in the history
See:

* https://github.com/ember-cli/rfcs/blob/master/complete/0095-standardise-targets.md
* https://emberjs.com/blog/2017/03/19/ember-2-12-released.html#toc_targets

On older ember-cli versions `project.targets` is undefined, which would cause
the default autoprefixer results (same as prior to this change).

On newer ember-cli versions the projects own targets are used and manual configuration
in `ember-cli-build.js` is not needed.
  • Loading branch information
rwjblue authored and kimroen committed Apr 22, 2017
1 parent 018ca25 commit d339c9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -10,8 +10,9 @@ ember install ember-cli-autoprefixer
```

## Options
You can configure what browsers to target and other options by specifying them in your
`ember-cli-build.js` (or `Brocfile.js`). An example:
By default ember-cli-autoprefixer passes your projects target browsers (in Ember CLI >= 2.13.0)
to autoprefixer. However, you can manually configure what browsers to target and other options by
specifying them in your `ember-cli-build.js` (or `Brocfile.js`). An example:

```js
var app = new EmberApp(defaults, {
Expand Down
7 changes: 6 additions & 1 deletion index.js
Expand Up @@ -6,20 +6,25 @@ var defaults = require('lodash/defaults');

module.exports = {
name: 'ember-cli-autoprefixer',
included: function(app, parentAddon) {

included: function(app) {
this.app = app;

if (typeof app.import !== 'function' && app.app) {
this.app = app = app.app;
}

this._super.included.apply(this, arguments);

this.options = defaults(this.app.options.autoprefixer || {}, {
browsers: this.project.targets && this.project.targets.browsers,
enabled: true
});

this.enabled = this.options.enabled;
delete this.options.enabled;
},

postprocessTree: function(type, tree) {
if ((type === 'all' || type === 'styles') && this.enabled) {
tree = autoprefixer(tree, this.options);
Expand Down

0 comments on commit d339c9b

Please sign in to comment.