1
1
/**
2
2
* Modules dependencies
3
3
*/
4
- var Postcss = require ( "postcss" )
4
+ var postcss = require ( "postcss" )
5
5
var assign = require ( "object-assign" )
6
6
var caniuse = require ( "caniuse-api" )
7
7
@@ -31,7 +31,7 @@ var caniuseFeaturesMap = {
31
31
// autoprefixer: [null] // will always be null since autoprefixer does the same game as we do
32
32
}
33
33
34
- var features = {
34
+ var libraryFeatures = {
35
35
// Reminder: order is important
36
36
customProperties : function ( options ) { return require ( "postcss-custom-properties" ) ( options ) } ,
37
37
calc : function ( options ) { return require ( "postcss-calc" ) ( options ) } ,
@@ -50,7 +50,7 @@ var features = {
50
50
pseudoClassMatches : function ( options ) { return require ( "postcss-selector-matches" ) ( options ) } ,
51
51
pseudoClassNot : function ( options ) { return require ( "postcss-selector-not" ) ( options ) } ,
52
52
colorRgba : function ( options ) { return require ( "postcss-color-rgba-fallback" ) ( options ) } ,
53
- autoprefixer : function ( options ) { return require ( "autoprefixer-core" ) ( options ) . postcss }
53
+ autoprefixer : function ( options ) { return require ( "autoprefixer-core" ) ( options ) . postcss } ,
54
54
}
55
55
56
56
/**
@@ -98,19 +98,19 @@ function cssnext(string, options) {
98
98
if ( features . autoprefixer . browsers === undefined ) { delete features . autoprefixer . browsers }
99
99
}
100
100
101
- var postcss = Postcss ( )
101
+ var postcssInstance = postcss ( )
102
102
103
103
// only enable import & url if fs module is available
104
104
var fs = require ( "fs" )
105
105
if ( fs && fs . readFile ) {
106
106
// @import
107
107
if ( options . import !== false ) {
108
- postcss . use ( require ( "postcss-import" ) ( typeof options . import === "object" ? options . import : undefined ) )
108
+ postcssInstance . use ( require ( "postcss-import" ) ( typeof options . import === "object" ? options . import : undefined ) )
109
109
}
110
110
111
111
// url() adjustements
112
112
if ( options . url !== false ) {
113
- postcss . use ( require ( "postcss-url" ) ( typeof options . url === "object" ? options . url : undefined ) )
113
+ postcssInstance . use ( require ( "postcss-url" ) ( typeof options . url === "object" ? options . url : undefined ) )
114
114
}
115
115
}
116
116
@@ -135,19 +135,19 @@ function cssnext(string, options) {
135
135
)
136
136
)
137
137
) {
138
- postcss . use ( cssnext . features [ key ] ( typeof features [ key ] === "object" ? features [ key ] : undefined ) )
138
+ postcssInstance . use ( cssnext . features [ key ] ( typeof features [ key ] === "object" ? features [ key ] : undefined ) )
139
139
}
140
140
} )
141
141
142
142
// minification
143
143
if ( options . compress ) {
144
144
var csswring = require ( "csswring" )
145
- postcss . use ( typeof options . compress === "object" ? csswring ( options . compress ) : csswring )
145
+ postcssInstance . use ( typeof options . compress === "object" ? csswring ( options . compress ) : csswring )
146
146
}
147
147
148
148
// classic API if string is passed
149
149
if ( typeof string === "string" ) {
150
- var result = postcss . process ( string , options )
150
+ var result = postcssInstance . process ( string , options )
151
151
152
152
// default behavior, cssnext returns a css string if no or inline sourcemap
153
153
if ( options . map === null || ( options . map === true || options . map . inline ) ) {
@@ -159,7 +159,7 @@ function cssnext(string, options) {
159
159
}
160
160
// or return the postcss instance that can be consumed as a postcss plugin
161
161
else {
162
- return postcss
162
+ return postcssInstance
163
163
}
164
164
}
165
165
@@ -168,4 +168,4 @@ function cssnext(string, options) {
168
168
*
169
169
* @type {Object }
170
170
*/
171
- cssnext . features = features
171
+ cssnext . features = libraryFeatures
0 commit comments