Search code examples
sasscompass-sass

Conditionally import partials - Compass


I'm trying to conditionally import a sass partial if it exists to override a set of default styling variables. I'm looking for a means to accomplish the following, given that @import directives cannot be nested:

 @if 'partials/theme'{
   @import 'partials/theme';
 }

Import directives may not be used within control directives or mixins, so what is the proper approach for referencing a partial that may or may not exist?


Solution

  • In retrospect, the best solution you would probably use JavaScript to conditionally load in theme assets or modules.