The SCSS @forward rule supports a couple nice features:
@forward './colors' show $red, $green, $blue;will only forward$red,$green, and$bluefrom./colors. All other values that./colorswould otherwise export are ignored.@forward 'library' with ($space: 2em);will make$spaceavailable to the library, overriding any default that library may have for$space.
How can I use these both together? In my case I'm using the include-media library. I want to define a module that wraps it like this (slightly simplified):
@forward 'include-media with (
$breakpoints: ( 'small': 400, 'medium': 700, 'large': 1000 )
) show media, media-context;
The goal here is to both provide the library the $breakpoints value it's expecting, and forward only the media and media-context mixins. Unfortunately that code fails to compile with this error:
Error: expected ";".
╷
3 │ ) show media, media-context;
│ ^
I get similar results if I put the show clause before the with clause.
It seems sub-optimal, but I could imagine this working with two files:
// file _withBreakpoints.scss
@forward 'include-media' with (
$breakpoints: ( 'small': 400, 'medium': 700, 'large': 1000 )
);
// file _filtered.scss
@forward './withBreakpoints' show media, media-context;
Surely there's a better way?