ember-cli-postcss
Advanced tools
Comparing version 1.0.0 to 1.1.0
31
index.js
var PostcssCompiler = require('broccoli-postcss'); | ||
var checker = require('ember-cli-version-checker'); | ||
function PostCSSPlugin (plugins, options) { | ||
// PostCSSPlugin constructor | ||
function PostCSSPlugin (options) { | ||
this.name = 'ember-cli-postcss'; | ||
options = options || {}; | ||
options.inputFile = options.inputFile || 'app.css'; | ||
options.outputFile = options.outputFile || 'app.css'; | ||
this.options = options; | ||
this.plugins = plugins; | ||
this.plugins = options.plugins; | ||
this.map = options.map; | ||
} | ||
PostCSSPlugin.prototype.toTree = function (tree, inputPath, outputPath, options) { | ||
PostCSSPlugin.prototype.toTree = function (tree, inputPath, outputPath) { | ||
var trees = [tree]; | ||
if (this.options.includePaths) trees = trees.concat(this.options.includePaths); | ||
if (this.options.includePaths) { | ||
trees = trees.concat(this.options.includePaths); | ||
} | ||
inputPath += '/' + this.options.inputFile; | ||
outputPath += '/' + this.options.outputFile; | ||
return new PostcssCompiler(trees, inputPath, outputPath, this.plugins); | ||
} | ||
return new PostcssCompiler(trees, inputPath, outputPath, this.plugins, this.map); | ||
}; | ||
module.exports = { | ||
@@ -28,8 +32,13 @@ name: 'Ember CLI Postcss', | ||
this.app = app; | ||
// Initialize options if none were passed | ||
var options = app.options.postcssOptions || {}; | ||
var plugins = this.plugins = options.plugins || []; | ||
// Set defaults if none were passed | ||
options.map = options.map || {}; | ||
options.plugins = options.plugins || []; | ||
options.inputFile = options.inputFile || 'app.css'; | ||
options.outputFile = options.outputFile || this.project.name() + '.css'; | ||
app.registry.add('css', new PostCSSPlugin(plugins, options)); | ||
// Add to registry and pass options | ||
app.registry.add('css', new PostCSSPlugin(options)); | ||
@@ -36,0 +45,0 @@ if (this.shouldSetupRegistryInIncluded()) { |
{ | ||
"name": "ember-cli-postcss", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Use postcss to process your css with a large selection of JavaScript plug-ins.", | ||
@@ -5,0 +5,0 @@ "repository": { |
# ember-cli-postcss | ||
[![npm version](https://badge.fury.io/js/ember-cli-postcss.svg)](http://badge.fury.io/js/ember-cli-postcss) [![Ember Observer Score](http://emberobserver.com/badges/ember-cli-postcss.svg)](http://emberobserver.com/addons/ember-cli-postcss) [![Code Climate](https://codeclimate.com/github/jeffjewiss/ember-cli-postcss/badges/gpa.svg)](https://codeclimate.com/github/jeffjewiss/ember-cli-postcss) | ||
Use [postcss](https://github.com/postcss/postcss) to process your `css` with a large selection of JavaScript plug-ins. | ||
@@ -42,10 +44,10 @@ | ||
```shell | ||
npm i --save-dev autoprefixer | ||
npm i --save-dev autoprefixer-core | ||
``` | ||
Specify some plugins in your Brocfile: | ||
Specify some plugins in your Brocfile.js: | ||
```javascript | ||
var EmberApp = require(‘ember-cli/lib/broccoli/ember-app’); | ||
var autoprefixer = require(‘autoprefixer-core’); | ||
var EmberApp = require('ember-cli/lib/broccoli/ember-app'); | ||
var autoprefixer = require('autoprefixer-core'); | ||
@@ -58,3 +60,3 @@ var app = new EmberApp({ | ||
options: { | ||
browsers: [‘last 2 version’] | ||
browsers: ['last 2 version'] | ||
} | ||
@@ -65,2 +67,4 @@ } | ||
}); | ||
module.exports = app.toTree(); | ||
``` |
Sorry, the diff of this file is not supported yet
5768
39
68