@@ -121,20 +121,25 @@ function parseCss(cssText, substitutionMap) {
121121 . replace ( / \/ \/ .* (? = \n | $ ) / g, '' ) // remove // comments
122122 )
123123 }
124+ const pattern = new RegExp ( `^\\d+\\.${ MAGIC_NUMBER } ` )
125+ function startsWithSubstitution ( line ) {
126+ return pattern . test ( line )
127+ }
124128 cssText = removeComments ( cssText )
125- const lines = cssText . split ( '\n' )
129+ const SEPARATOR = ';'
130+ const lines = cssText . split ( '\n' ) . reduce ( ( acc , line ) => acc . concat ( line . split ( SEPARATOR ) ) , [ ] )
131+ const processedLines = [ ]
126132 let styles = [ ]
127133 for ( let i = 0 ; i < lines . length ; i ++ ) {
128134 let line = lines [ i ] . trim ( )
129- if ( line . endsWith ( ';' ) ) {
130- line = line . substring ( 0 , line . length - 1 )
135+ if ( startsWithSubstitution ( line ) && substitutionMap [ line ] ) {
136+ line = ` ${ MIXIN } : ${ line } `
131137 }
132- if ( substitutionMap [ line ] ) { // mixin
133- styles . push ( [ MIXIN , line ] )
134- lines [ i ] = ''
138+ if ( line ) {
139+ processedLines . push ( line )
135140 }
136141 }
137- cssText = lines . join ( '' )
142+ cssText = processedLines . join ( SEPARATOR )
138143 const { nodes } = postcss . parse ( cssText )
139144 for ( const node of nodes ) {
140145 if ( node . type === 'decl' ) {
@@ -180,7 +185,7 @@ function buildCssObject(identifier, t, substitutions) {
180185 const elements = [ ]
181186 const expressions = [ ]
182187 if ( substitutions [ value ] ) {
183- return substitutions [ value ]
188+ return inject ( substitutions [ value ] )
184189 }
185190 const matches = splitSubstitution ( value )
186191 for ( const match of matches ) {
0 commit comments