Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf22dbd
commit 2362ca4
Showing
10 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# PostCSS | ||
This is the compiler interface to [PostCSS](https://github.com/postcss/postcss). PostCSS is a tool for transforming CSS with JS plugins. These plugins can support variables and mixins, transpile future CSS syntax, inline images, and more. | ||
|
||
## Supported Methods | ||
- render | ||
|
||
## Source Maps | ||
|
||
Source maps are supported by the PostCSS adapter. Just pass in a `map` option [as described in the docs](https://github.com/postcss/postcss#source-map), and it will come back as `sourcemap` on the response object. | ||
|
||
## Additional Options | ||
### [Use](https://github.com/postcss/postcss/blob/master/API.md#processoruseplugin) | ||
|
||
- key: `use` | ||
- type: `Array|Function|Object` | ||
- default: `[]` | ||
|
||
Adds one or more plugins to be used as a CSS processor. | ||
|
||
```coffee | ||
pcss = accord.load('postcss') | ||
varPlugin = require('postcss-simple-vars') | ||
|
||
pcss.render( | ||
'$color: green;\n\n.test { background: $color; }' | ||
use: [varPlugin] | ||
).catch( | ||
(err) -> console.error err | ||
).done( | ||
(res) -> console.log res.result | ||
) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Adapter = require '../adapter_base' | ||
W = require 'when' | ||
_ = require 'lodash' | ||
sourcemaps = require '../sourcemaps' | ||
|
||
class PostCSS extends Adapter | ||
name: 'postcss' | ||
extensions: ['css'] | ||
output: 'css' | ||
|
||
_render: (str, options) -> | ||
use = options.use ? [] | ||
processor = @engine(use) | ||
|
||
options.map = {inline: false} if options.map is true | ||
|
||
W(processor.process(str, options)) | ||
.then (res) -> | ||
{ result: res.css, sourcemap: res.map } | ||
|
||
module.exports = PostCSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.test2 { | ||
color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.test2 { | ||
color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.test { color: green; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.test { | ||
background: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$color: green; | ||
|
||
.test { | ||
background: $color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters