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 {
26
26
}
27
27
28
28
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 ] )
33
41
} )
34
42
}
35
43
@@ -57,7 +65,7 @@ export default class Parser {
57
65
return this . pathFetcher ( file , relativeTo , depTrace ) . then ( exports => {
58
66
importNode . each ( decl => {
59
67
if ( decl . type == 'decl' ) {
60
- this . translations [ decl . prop ] = exports [ decl . value ]
68
+ this . translations [ decl . prop ] = exports [ decl . value ] . replace ( / ^ [ ' " ] | [ ' " ] $ / g , '' )
61
69
}
62
70
} )
63
71
importNode . removeSelf ( )
Original file line number Diff line number Diff line change 1
- : exports {
1
+ : export {
2
2
--small : "(max-width: 30em)" ;
3
3
--medium : "(max-width: 60em)" ;
4
4
--large : "(max-width: 90em)" ;
Original file line number Diff line number Diff line change 1
1
@custom-media --small (max-width : 30em );
2
2
@custom-media --medium (max-width : 60em );
3
3
@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 );
4
7
5
8
.exported-red {
6
9
color : red;
Original file line number Diff line number Diff line change 1
1
{
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"
5
6
}
You can’t perform that action at this time.
0 commit comments