@@ -11,7 +11,9 @@ var caniuse = require("caniuse-api")
11
11
// null == always enable (& no caniuse data)
12
12
var caniuseFeaturesMap = {
13
13
customProperties : [ "css-variables" ] ,
14
- // calc: null, // calc() transformation only make sense with transformed custom properties, don't you think ?
14
+ // calc() transformation only make sense with transformed custom properties,
15
+ // don't you think ?
16
+ // calc: null,
15
17
// @todo open PR on caniuse repo https://github.com/Fyrd/caniuse
16
18
// customMedia: [null],
17
19
// mediaQueriesRange: [null],
@@ -22,44 +24,75 @@ var caniuseFeaturesMap = {
22
24
// colorHexAlpha: [null],
23
25
// colorFunction:[null],
24
26
// fontVariant: [null],
25
- // filter: [null], // @todo can be done using a callback, this is only used for Firefox < 35
27
+ // @todo can be done using a callback, this is only used for Firefox < 35
28
+ // filter: [null],
26
29
rem : [ "rem" ] ,
27
30
pseudoElements : [ "css-gencontent" ] ,
28
31
// pseudoClassMatches: [null],
29
32
// pseudoClassNot: [null],
30
33
colorRgba : [ "css3-colors" ] ,
31
- // autoprefixer: [null] // will always be null since autoprefixer does the same game as we do
34
+ // will always be null since autoprefixer does the same game as we do
35
+ // autoprefixer: [null]
32
36
}
33
37
34
38
var libraryFeatures = {
35
39
// Reminder: order is important
36
- customProperties : function ( options ) { return require ( "postcss-custom-properties" ) ( options ) } ,
37
- calc : function ( options ) { return require ( "postcss-calc" ) ( options ) } ,
38
- customMedia : function ( options ) { return require ( "postcss-custom-media" ) ( options ) } ,
39
- mediaQueriesRange : function ( options ) { return require ( "postcss-media-minmax" ) ( options ) } ,
40
- customSelectors : function ( options ) { return require ( "postcss-custom-selectors" ) ( options ) } ,
41
- colorRebeccapurple : function ( options ) { return require ( "postcss-color-rebeccapurple" ) ( options ) } ,
42
- colorHwb : function ( options ) { return require ( "postcss-color-hwb" ) ( options ) } ,
43
- colorGray : function ( options ) { return require ( "postcss-color-gray" ) ( options ) } ,
44
- colorHexAlpha : function ( options ) { return require ( "postcss-color-hex-alpha" ) ( options ) } ,
45
- colorFunction : function ( options ) { return require ( "postcss-color-function" ) ( options ) } ,
46
- fontVariant : function ( options ) { return require ( "postcss-font-variant" ) ( options ) } ,
47
- filter : function ( options ) { return require ( "pleeease-filters" ) ( options ) } ,
48
- rem : function ( options ) { return require ( "pixrem" ) ( options ) } ,
49
- pseudoElements : function ( options ) { return require ( "postcss-pseudoelements" ) ( options ) } ,
50
- pseudoClassMatches : function ( options ) { return require ( "postcss-selector-matches" ) ( options ) } ,
51
- pseudoClassNot : function ( options ) { return require ( "postcss-selector-not" ) ( options ) } ,
52
- colorRgba : function ( options ) { return require ( "postcss-color-rgba-fallback" ) ( options ) } ,
53
- autoprefixer : function ( options ) { return require ( "autoprefixer-core" ) ( options ) . postcss } ,
40
+ customProperties : function ( options ) {
41
+ return require ( "postcss-custom-properties" ) ( options )
42
+ } ,
43
+ calc : function ( options ) {
44
+ return require ( "postcss-calc" ) ( options )
45
+ } ,
46
+ customMedia : function ( options ) {
47
+ return require ( "postcss-custom-media" ) ( options )
48
+ } ,
49
+ mediaQueriesRange : function ( options ) {
50
+ return require ( "postcss-media-minmax" ) ( options )
51
+ } ,
52
+ customSelectors : function ( options ) {
53
+ return require ( "postcss-custom-selectors" ) ( options )
54
+ } ,
55
+ colorRebeccapurple : function ( options ) {
56
+ return require ( "postcss-color-rebeccapurple" ) ( options )
57
+ } ,
58
+ colorHwb : function ( options ) {
59
+ return require ( "postcss-color-hwb" ) ( options )
60
+ } ,
61
+ colorGray : function ( options ) {
62
+ return require ( "postcss-color-gray" ) ( options )
63
+ } ,
64
+ colorHexAlpha : function ( options ) {
65
+ return require ( "postcss-color-hex-alpha" ) ( options )
66
+ } ,
67
+ colorFunction : function ( options ) {
68
+ return require ( "postcss-color-function" ) ( options )
69
+ } ,
70
+ fontVariant : function ( options ) {
71
+ return require ( "postcss-font-variant" ) ( options )
72
+ } ,
73
+ filter : function ( options ) {
74
+ return require ( "pleeease-filters" ) ( options )
75
+ } ,
76
+ rem : function ( options ) {
77
+ return require ( "pixrem" ) ( options )
78
+ } ,
79
+ pseudoElements : function ( options ) {
80
+ return require ( "postcss-pseudoelements" ) ( options )
81
+ } ,
82
+ pseudoClassMatches : function ( options ) {
83
+ return require ( "postcss-selector-matches" ) ( options )
84
+ } ,
85
+ pseudoClassNot : function ( options ) {
86
+ return require ( "postcss-selector-not" ) ( options )
87
+ } ,
88
+ colorRgba : function ( options ) {
89
+ return require ( "postcss-color-rgba-fallback" ) ( options )
90
+ } ,
91
+ autoprefixer : function ( options ) {
92
+ return require ( "autoprefixer-core" ) ( options ) . postcss
93
+ } ,
54
94
}
55
95
56
- /**
57
- * Expose cssnext
58
- *
59
- * @type {Function }
60
- */
61
- module . exports = cssnext
62
-
63
96
/**
64
97
* Process a CSS `string`
65
98
*
@@ -83,7 +116,8 @@ function cssnext(string, options) {
83
116
84
117
var features = options . features || { }
85
118
86
- // options.browsers is deliberately undefined by defaut to inherit browserslist default behavior
119
+ // options.browsers is deliberately undefined by defaut to inherit
120
+ // browserslist default behavior
87
121
88
122
// default sourcemap
89
123
// if `map` option is passed, `sourcemap` option is ignored
@@ -93,9 +127,13 @@ function cssnext(string, options) {
93
127
// propagate browsers option to autoprefixer
94
128
if ( features . autoprefixer !== false ) {
95
129
features . autoprefixer = features . autoprefixer || { }
96
- features . autoprefixer . browsers = features . autoprefixer . browsers || options . browsers
130
+ features . autoprefixer . browsers = features . autoprefixer . browsers ||
131
+ options . browsers
132
+
97
133
// autoprefixer doesn't like an "undefined" value. Related to coffee ?
98
- if ( features . autoprefixer . browsers === undefined ) { delete features . autoprefixer . browsers }
134
+ if ( features . autoprefixer . browsers === undefined ) {
135
+ delete features . autoprefixer . browsers
136
+ }
99
137
}
100
138
101
139
var postcssInstance = postcss ( )
@@ -105,18 +143,29 @@ function cssnext(string, options) {
105
143
if ( fs && fs . readFile ) {
106
144
// @import
107
145
if ( options . import !== false ) {
108
- postcssInstance . use ( require ( "postcss-import" ) ( typeof options . import === "object" ? options . import : undefined ) )
146
+ postcssInstance . use ( require ( "postcss-import" ) (
147
+ typeof options . import === "object"
148
+ ? options . import
149
+ : undefined
150
+ )
151
+ )
109
152
}
110
153
111
154
// url() adjustements
112
155
if ( options . url !== false ) {
113
- postcssInstance . use ( require ( "postcss-url" ) ( typeof options . url === "object" ? options . url : undefined ) )
156
+ postcssInstance . use ( require ( "postcss-url" ) (
157
+ typeof options . url === "object"
158
+ ? options . url
159
+ : undefined
160
+ )
161
+ )
114
162
}
115
163
}
116
164
117
165
// features
118
166
Object . keys ( cssnext . features ) . forEach ( function ( key ) {
119
- // feature is auto enabled if: not disable && (enabled || no data yet || !supported yet)
167
+ // feature is auto enabled if: not disable && (enabled || no data yet ||
168
+ // !supported yet)
120
169
if (
121
170
// feature is not disabled
122
171
features [ key ] !== false &&
@@ -135,7 +184,12 @@ function cssnext(string, options) {
135
184
)
136
185
)
137
186
) {
138
- postcssInstance . use ( cssnext . features [ key ] ( typeof features [ key ] === "object" ? features [ key ] : undefined ) )
187
+ postcssInstance . use ( cssnext . features [ key ] (
188
+ typeof features [ key ] === "object"
189
+ ? features [ key ]
190
+ : undefined
191
+ )
192
+ )
139
193
}
140
194
} )
141
195
@@ -178,3 +232,10 @@ function cssnext(string, options) {
178
232
* @type {Object }
179
233
*/
180
234
cssnext . features = libraryFeatures
235
+
236
+ /**
237
+ * Expose cssnext
238
+ *
239
+ * @type {Function }
240
+ */
241
+ module . exports = cssnext
0 commit comments