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) {
306306 } ) ) ;
307307 const varsOverride = oVariableCollector . getAllVariables ( ) ;
308308 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
309312
310313 let cssSkeletonRtl ;
311314 if ( oRTL ) {
Original file line number Diff line number Diff line change @@ -87,19 +87,25 @@ CSSVariablesCollectorPlugin.prototype = {
8787 const variableValue = this . calcVars [ value ] . css ;
8888 lessVariables += `@${ variableName } : ${ variableValue } ;\n` ;
8989 } ) ;
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` ;
9998 }
10099 } ) ;
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 ;
103109 } ,
104110
105111 _getCSS ( node ) {
You can’t perform that action at this time.
0 commit comments