File tree Expand file tree Collapse file tree 4 files changed +49
-12
lines changed
Expand file tree Collapse file tree 4 files changed +49
-12
lines changed Original file line number Diff line number Diff line change 11### HEAD
22
3+ * Add ` debug ` option to pass an ` postcss-debug ` instance
34* Allow usage of ` transform ` and ` onImport ` in ` postcss-easy-import `
45* Remove ` beforeLint ` feature
56* Add default browsers list for autoprefixer
Original file line number Diff line number Diff line change @@ -94,6 +94,35 @@ preprocessor(css, {
9494
9595Where to resolve imports from. Passed to [ ` postcss-import ` ] ( https://github.com/postcss/postcss-import/blob/master/README.md#root ) .
9696
97+ ##### ` debug `
98+
99+ * Type: ` Function `
100+ * Default: identity (it does nothing)
101+
102+ Before preprocessing ` debug ` is invoked on the postcss ` plugins ` array.
103+ This allows you to pass a [ ` postcss-debug ` ] ( https://www.npmjs.com/package/postcss-debug ) instance.
104+
105+ ``` javascript
106+ var preprocessor = require (' suitcss-preprocessor' );
107+ var createDebugger = require (' postcss-debug' ).createDebugger ;
108+ var debug = createDebugger ();
109+
110+ preprocessor (css, {
111+ debug: debug
112+ }).then (function () {
113+ debug .inspect ();
114+ });
115+ ```
116+
117+ N.B. ` debug ` should always take one argument that is ` plugins ` and eventually return it:
118+
119+ ``` javascript
120+ function debug (plugins ) {
121+ // do something with plugins here
122+ return plugins;
123+ }
124+ ```
125+
97126##### ` lint `
98127
99128* Type: ` Boolean `
Original file line number Diff line number Diff line change @@ -11,12 +11,14 @@ var stylelintConfigSuit = require('stylelint-config-suitcss');
1111module . exports = preprocessor ;
1212
1313/**
14- * Default options to PostCSS plugins
14+ * Default configuration
15+ * and options to PostCSS plugins
1516 */
1617
1718var defaults = {
18- minify : false ,
19+ debug : identity ,
1920 lint : false ,
21+ minify : false ,
2022 use : [
2123 'postcss-easy-import' ,
2224 'postcss-custom-properties' ,
@@ -62,7 +64,7 @@ function preprocessor(css, options) {
6264 return settings ? plugin ( settings ) : plugin ;
6365 } ) ;
6466
65- var processor = postcss ( plugins ) ;
67+ var processor = postcss ( options . debug ( plugins ) ) ;
6668
6769 if ( options . minify ) {
6870 processor . use ( cssnano ( options . cssnano ) ) ;
Original file line number Diff line number Diff line change @@ -41,15 +41,7 @@ describe('suitcss', function() {
4141 } ) ;
4242
4343 it ( 'should use default options when nothing is passed' , function ( ) {
44- var keys = [
45- 'autoprefixer' ,
46- 'minify' ,
47- 'use' ,
48- 'lint' ,
49- 'postcss-easy-import' ,
50- 'postcss-reporter' ,
51- 'cssnano'
52- ] ;
44+ var keys = Object . keys ( defaults ) ;
5345 expect ( mergeOptions ( { } ) ) . to . have . keys ( keys ) ;
5446 expect ( mergeOptions ( ) ) . to . have . keys ( keys ) ;
5547 expect ( mergeOptions ( { } ) . use ) . to . eql ( defaults . use ) ;
@@ -61,6 +53,19 @@ describe('suitcss', function() {
6153 expect ( opts [ 'postcss-easy-import' ] . root ) . to . equal ( 'test/root' ) ;
6254 } ) ;
6355
56+ it ( 'should allow a debug function to be ran on plugins' , function ( done ) {
57+ var debug = sinon . spy ( function ( plugins ) {
58+ return plugins ;
59+ } ) ;
60+
61+ suitcss ( 'body {}' , {
62+ debug : debug
63+ } ) . then ( function ( ) {
64+ expect ( debug . calledOnce ) . to . be . true ;
65+ done ( ) ;
66+ } ) . catch ( done ) ;
67+ } ) ;
68+
6469 it ( 'should allow stylelint to be enabled' , function ( ) {
6570 var opts = mergeOptions ( { lint : true } ) ;
6671 expect ( opts . lint ) . to . be . true ;
You can’t perform that action at this time.
0 commit comments