Skip to content

Instantly share code, notes, and snippets.

@stoyanvi
Last active July 1, 2020 13:20
Show Gist options
  • Save stoyanvi/3c24774c3f4a110e447d to your computer and use it in GitHub Desktop.
Save stoyanvi/3c24774c3f4a110e447d to your computer and use it in GitHub Desktop.
Prevent styles from being loaded multiple times for components that rely on other components.
// IMPORT ONCE
// Prevent styles from being loaded multiple times for components that rely on other components.
$modules: () !default;
@mixin exports($name) {
$module_index: index($modules, $name);
@if not index($modules, $name) {
$modules: append($modules, $name) !global;
@content;
}
}
// File: components/_fancy-button.scss
@include exports('fancy-button') {
.fancyButton {
@include koko(#000);
}
}
@import 'components/_fancy-button.scss';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment