File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,9 @@ Builder.prototype.build = function(options) {
306
306
} ) ) ;
307
307
const varsOverride = oVariableCollector . getAllVariables ( ) ;
308
308
const cssVariablesSource = oCSSVariablesCollector . toLessVariables ( varsOverride ) ;
309
+ // eslint-disable-next-line no-unused-vars
310
+ const cssVariablesOnly = oCSSVariablesCollector . getCssVariablesDeclaration ( ) ;
311
+ // TODO: export cssVariablesOnly so that it can be written as css_variables_only.less
309
312
310
313
let cssSkeletonRtl ;
311
314
if ( oRTL ) {
Original file line number Diff line number Diff line change @@ -87,19 +87,25 @@ CSSVariablesCollectorPlugin.prototype = {
87
87
const variableValue = this . calcVars [ value ] . css ;
88
88
lessVariables += `@${ variableName } : ${ variableValue } ;\n` ;
89
89
} ) ;
90
- lessVariables += "\n:root {\n" ;
91
- Object . keys ( vars ) . forEach ( ( value , index ) => {
92
- if ( vars [ value ] . export ) {
93
- lessVariables += `--${ value } : @${ value } ;\n` ;
94
- }
95
- } ) ;
96
- Object . keys ( this . calcVars ) . forEach ( ( value , index ) => {
97
- if ( this . calcVars [ value ] . export ) {
98
- lessVariables += `--${ value } : @${ value } ;\n` ;
90
+ lessVariables += "\n" + this . getCssVariablesDeclaration ( { includeCalcVars : true } ) ;
91
+ return lessVariables ;
92
+ } ,
93
+ getCssVariablesDeclaration ( { includeCalcVars = false } = { } ) {
94
+ let content = ":root {\n" ;
95
+ Object . keys ( this . vars ) . forEach ( ( value ) => {
96
+ if ( this . vars [ value ] . export ) {
97
+ content += `--${ value } : @${ value } ;\n` ;
99
98
}
100
99
} ) ;
101
- lessVariables += "}\n" ;
102
- return lessVariables ;
100
+ if ( includeCalcVars ) {
101
+ Object . keys ( this . calcVars ) . forEach ( ( value ) => {
102
+ if ( this . calcVars [ value ] . export ) {
103
+ content += `--${ value } : @${ value } ;\n` ;
104
+ }
105
+ } ) ;
106
+ }
107
+ content += "}\n" ;
108
+ return content ;
103
109
} ,
104
110
105
111
_getCSS ( node ) {
You can’t perform that action at this time.
0 commit comments