File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed
Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,18 @@ export default class Parser {
2626 }
2727
2828 linkImportedSymbols ( css ) {
29- css . eachDecl ( decl => {
30- Object . keys ( this . translations ) . forEach ( translation => {
31- decl . value = decl . value . replace ( translation , this . translations [ translation ] )
32- } )
29+ css . eachInside ( node => {
30+ if ( node . type === "decl" ) {
31+ this . replaceOccurrences ( node , "value" )
32+ } else if ( node . type === "atrule" && node . name === "custom-media" ) {
33+ this . replaceOccurrences ( node , "params" )
34+ }
35+ } )
36+ }
37+
38+ replaceOccurrences ( node , prop ) {
39+ Object . keys ( this . translations ) . forEach ( translation => {
40+ node [ prop ] = node [ prop ] . replace ( translation , this . translations [ translation ] )
3341 } )
3442 }
3543
@@ -57,7 +65,7 @@ export default class Parser {
5765 return this . pathFetcher ( file , relativeTo , depTrace ) . then ( exports => {
5866 importNode . each ( decl => {
5967 if ( decl . type == 'decl' ) {
60- this . translations [ decl . prop ] = exports [ decl . value ]
68+ this . translations [ decl . prop ] = exports [ decl . value ] . replace ( / ^ [ ' " ] | [ ' " ] $ / g , '' )
6169 }
6270 } )
6371 importNode . removeSelf ( )
Original file line number Diff line number Diff line change 1- : exports {
1+ : export {
22 --small : "(max-width: 30em)" ;
33 --medium : "(max-width: 60em)" ;
44 --large : "(max-width: 90em)" ;
Original file line number Diff line number Diff line change 11@custom-media --small (max-width : 30em );
22@custom-media --medium (max-width : 60em );
33@custom-media --large (max-width : 90em );
4+ @custom-media --small (max-width : 30em );
5+ @custom-media --medium (max-width : 60em );
6+ @custom-media --large (max-width : 90em );
47
58.exported-red {
69 color : red;
Original file line number Diff line number Diff line change 11{
2- "--small" : " --x__source__small" ,
3- "--medium" : " --x__source__medium" ,
4- "--large" : " --x__source__large"
2+ "--small" : " (max-width: 30em)" ,
3+ "--medium" : " (max-width: 60em)" ,
4+ "--large" : " (max-width: 90em)" ,
5+ "red" : " exported-red"
56}
You can’t perform that action at this time.
0 commit comments