Skip to content

Commit

Permalink
Merge pull request #7 from kimroen/adding-disabling
Browse files Browse the repository at this point in the history
Add support for disabling autoprefixer
  • Loading branch information
kimroen committed Jan 31, 2015
2 parents 0f9902f + e5043f8 commit f71a342
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -27,6 +27,8 @@ var app = new EmberApp({
This would prefix styles as required by the two latest version of ios, and disable the cascade (see below).
The default value for `browsers` are `['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']`.

You can disable autoprefixer by passing in `enabled: false`.

Other options, such as [cascade](https://github.com/ai/autoprefixer#visual-cascade) and [sourcemap](https://github.com/sindresorhus/broccoli-autoprefixer#sourcemap) would also go here along with `browsers`.

You can read more about this setting and others [over on the autoprefixer page](https://github.com/ai/autoprefixer#browsers) and/or the [page for broccoli-autoprefixer](https://github.com/sindresorhus/broccoli-autoprefixer#options).
Expand Down
9 changes: 7 additions & 2 deletions index.js
Expand Up @@ -3,14 +3,15 @@
var path = require('path');
var fs = require('fs');
var autoprefixer = require('broccoli-autoprefixer');
var defaults = require('lodash').defaults;

function EmberCLIAutoprefixer(project) {
this.project = project;
this.name = 'Ember CLI Autoprefixer';
}

EmberCLIAutoprefixer.prototype.postprocessTree = function (type, tree) {
if (type === 'all' || type === 'styles') {
if ((type === 'all' || type === 'styles') && this.enabled) {
tree = autoprefixer(tree, this.options);
}

Expand All @@ -19,7 +20,11 @@ EmberCLIAutoprefixer.prototype.postprocessTree = function (type, tree) {

EmberCLIAutoprefixer.prototype.included = function included(app) {
this.app = app;
this.options = this.app.options.autoprefixer;
this.options = defaults(this.app.options.autoprefixer || {}, {
enabled: true
});
this.enabled = this.options.enabled;
delete this.options.enabled;
};

EmberCLIAutoprefixer.prototype.treeFor = function treeFor() {};
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -19,7 +19,8 @@
"author": "Kim Røen",
"license": "MIT",
"dependencies": {
"broccoli-autoprefixer": "^2.0.0"
"broccoli-autoprefixer": "^2.0.0",
"lodash": "^3.0.1"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f71a342

Please sign in to comment.