-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Hi, so I wrote a PostCSS plugin for responsive values, and where you define a couple of branches for a value for different media queries with intended use looking like this
@value fontSize: media-value(
case: "a" as: "18px",
case: "b" as: "16px",
case: "c" as: "16px",
case: "d" as: "14px",
else: "14px",
);
.fontDef {
font-size: fontSize;
}I would have expected without adding my plugin css modules would have copied the value of fontSize into the rule fontDef and you would have output like:
.fontDef {
font-size: media-value(
case: "a" as: "18px",
case: "b" as: "16px",
case: "c" as: "16px",
case: "d" as: "14px",
else: "14px",
);
}So when my plugin passed over it, it could expand the value over the rule so I would get
.fontDef {
font-size: 14px;
}
@media a { .fontDef { font-size: 18px; } }
@media b { .fontDef { font-size: 16px; } }
@media c { .fontDef { font-size: 16px; } }
@media d { .fontDef { font-size: 14px; } }But it turns out the CSS remains completely untransformed from the original CSS, am I missing something? Is because the value defined is too gnarly for CSS Modules to interpret?
Update
So it turns out if I remove all new lines from the value the output is correct. So if it's like this....
@value fontSize: media-value(case: "a" as: "18px", case: "b" as: "16px", case: "c" as: "16px", case: "d" as: "14px", else: "14px");
.fontDef {
font-size: fontSize;
}CSS Modules transforms the value into this
.fontDef {
font-size: media-value(case: "a" as: "18px", case: "b" as: "16px", case: "c" as: "16px", case: "d" as: "14px", else: "14px");
}Questions! (Update 2)
- Does this qualify as a bug? If so are you open to pull requests :)
- Would a valid workaround be...
- Having a plugin in the
beforeplugin group, to strip the newlines from@valueAtRules - Then having the original PostCSS Plugin in the
afterplugin group in the config to operate on the version with new lines stripped - Would this work in the mean time?
- Having a plugin in the
Reactions are currently unavailable