Forked from paulwellnerbou/import-once-workaround.scss
Created
January 11, 2017 21:35
-
-
Save carlohcs/6b258495ece379a17ec74f1f291b7d21 to your computer and use it in GitHub Desktop.
Function for SASS/SCSS to avoid duplicate imports and redundant generated CSS. See http://paul.wellnerbou.de/2015/05/18/avoid-multiple-imports-of-the-same-scss-file-with-sass/ for more details.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* If this function is imported, you can import scss files using: | |
@if not-imported("your-file") { @import "your-file"; } | |
*/ | |
$imported-once-files: () !default; | |
@function not-imported($name) { | |
$imported-once-files: $imported-once-files !global; | |
$module_index: index($imported-once-files, $name); | |
@if (($module_index == null) or ($module_index == false)) { | |
$imported-once-files: append($imported-once-files, $name); | |
@return true; | |
} | |
@return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment