Skip to content

Commit bbd8d7f

Browse files
committed
Allow options to be passed to postcss
Fixes #22
1 parent 7e15c67 commit bbd8d7f

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ Third paramater is the options object containing any PostCSS configuration you m
153153
}
154154
```
155155

156+
##### `postcss`
157+
158+
* Type: `Object`
159+
* Default: `undefined`
160+
161+
Options that are passed directly to `postcss`, as per [the documentation](https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts).
162+
163+
```js
164+
{
165+
postcss: {from: 'filename.css'}
166+
}
167+
```
168+
169+
156170
##### `use`
157171

158172
* Type: `Array`

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function preprocessor(css, options) {
7575
processor.use(cssnano(options.cssnano));
7676
}
7777

78-
return processor.process(css);
78+
return processor.process(css, options.postcss);
7979
}
8080

8181
/**

test/test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,37 @@ describe('suitcss', function() {
8080
expect(opts['postcss-import'].root).to.equal('test/root');
8181
});
8282

83+
describe('passing options to postcss', function() {
84+
var postcssStub, processMethodStub, revert;
85+
86+
beforeEach(function() {
87+
postcssStub = sinon.stub();
88+
processMethodStub = sinon.stub();
89+
90+
postcssStub.returns({
91+
use: sinon.spy(),
92+
process: processMethodStub
93+
});
94+
revert = suitcss.__set__('postcss', postcssStub);
95+
suitcss('body {}', {
96+
root: 'something',
97+
postcss: {
98+
from: 'somefile.css'
99+
}
100+
});
101+
});
102+
103+
afterEach(function() {
104+
revert();
105+
});
106+
107+
it('should pass postcss options to the processor', function() {
108+
expect(processMethodStub.getCall(0).args[1]).to.eql({
109+
from: 'somefile.css'
110+
});
111+
});
112+
});
113+
83114
describe('re-ordering plugins', function() {
84115
it('should allow reordering of use array and remove duplicates', function() {
85116
var opts = mergeOptions({

0 commit comments

Comments
 (0)