@@ -49,12 +49,10 @@ var defaults = {
4949 preserveInjectedVariables : true
5050} ;
5151
52- module . exports = postcss . plugin ( 'postcss-css-variables' , function ( options ) {
52+ const cssvariables = postcss . plugin ( 'postcss-css-variables' , function ( options ) {
5353
5454 var opts = Object . assign ( { } , defaults , options ) ;
5555
56- // Work with opts here
57-
5856 return function ( css , result ) {
5957 // Map of variable names to a list of declarations
6058 let map = { } ;
@@ -140,6 +138,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
140138 return ;
141139 }
142140
141+ // TODO: Is there a way to walk the decls backwards so we can get the @media queries in the correct order
143142 const newUsageDecl = expandVarUsageFromVarDefinition ( variableEntry , variableDecl , usageDecl ) ;
144143 // Keep track of the cloned decls we should skip over
145144 usageDeclsToSkip . push ( newUsageDecl ) ;
@@ -160,7 +159,7 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
160159
161160 // Clean up the rule that declared them if it doesn't have anything left after we potentially remove the variable decl
162161 let currentNodeToCheckEmpty = variableDeclParentRule ;
163- while ( currentNodeToCheckEmpty . nodes . length === 0 ) {
162+ while ( currentNodeToCheckEmpty && currentNodeToCheckEmpty . nodes . length === 0 ) {
164163 const nodeToRemove = currentNodeToCheckEmpty ;
165164 currentNodeToCheckEmpty = nodeToRemove . parent ;
166165 nodeToRemove . remove ( ) ;
@@ -255,3 +254,6 @@ module.exports = postcss.plugin('postcss-css-variables', function(options) {
255254
256255 } ;
257256} ) ;
257+
258+
259+ module . exports = cssvariables ;
0 commit comments