@@ -150,6 +150,20 @@ CSSVariablesCollectorPlugin.prototype = {
150
150
} ,
151
151
152
152
visitRule ( node , visitArgs ) {
153
+ // check rule for being a variable declaration
154
+ const isVarDeclaration = typeof node . name === "string" && node . name . startsWith ( "@" ) ;
155
+ if ( ! this . _isInMixinOrParen ( ) && isVarDeclaration ) {
156
+ // add the variable declaration to the list of vars
157
+ const varName = node . name . substr ( 1 ) ;
158
+ const isVarInLib = this . _isVarInLibrary ( {
159
+ varName,
160
+ filename : node . currentFileInfo . filename
161
+ } ) ;
162
+ this . vars [ varName ] = {
163
+ css : this . _getCSS ( node . value ) ,
164
+ export : isVarInLib
165
+ } ;
166
+ }
153
167
// store the rule context for the call variable extraction
154
168
this . ruleStack . push ( node ) ;
155
169
return node ;
@@ -185,24 +199,6 @@ CSSVariablesCollectorPlugin.prototype = {
185
199
return node ;
186
200
} ,
187
201
188
- visitRuleset ( node , visitArgs ) {
189
- node . rules . forEach ( ( value ) => {
190
- const isVarDeclaration = value instanceof less . tree . Rule && typeof value . name === "string" && value . name . startsWith ( "@" ) ;
191
- if ( ! this . _isInMixinOrParen ( ) && isVarDeclaration ) {
192
- // add the variable declaration to the list of vars
193
- const varName = value . name . substr ( 1 ) ;
194
- this . vars [ varName ] = {
195
- css : this . _getCSS ( value . value ) ,
196
- export : this . _isVarInLibrary ( {
197
- varName,
198
- filename : value . currentFileInfo . filename
199
- } )
200
- } ;
201
- }
202
- } ) ;
203
- return node ;
204
- } ,
205
-
206
202
visitUrl ( node , visitArgs ) {
207
203
// we mark the less variables which should be updated after eval
208
204
// => strangewise less variables with "none" values are also urls
0 commit comments