Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

ignoring @if variable-exists() #152

Closed
dgrebb opened this issue Oct 31, 2014 · 4 comments
Closed

ignoring @if variable-exists() #152

dgrebb opened this issue Oct 31, 2014 · 4 comments

Comments

@dgrebb
Copy link

dgrebb commented Oct 31, 2014

Howdy,

I'm defining variables for font includes and only importing them if they exist:

in _config.scss:

// =========================
// Global Config
// =========================

// Font Stacks

$font-url--google           :   'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900';

$font-family--primary       :   'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
$font-family--secondary     :   'Helvetica Neue', Helvetica, Arial, sans-serif;

in _utilities.scss:

// ==========================
// Utilities
// ==========================

// Import if Google Fonts URL is defined

@if variable-exists(font-url--google) {
    @import url($font-url--google);
}

// Import if Typekit Fonts are defined
@if variable-exists(font-url--typekit) {
    @import url($font-url--typekit);
}

and in styles.scss:

@import 'config';
@import 'helpers';
@import 'utilities';
@import 'base';

gulp output:

Error: error /Users/dgrebb/Projects/tbi-dev-utils/development-standards/css/sass-template/src/scss/_utilities.scss (Line 13: Undefined variable: "$font-url--typekit".)

It appears ruby sass is ignoring the if() introspection function and running @import anyway?

@robwierzbowski
Copy link
Contributor

Gulp ruby sass just runs Sass and has no effect on parsing or output. Try running gulp [your sass command] --verbose to get the Sass command that it runs, and then run that command manually to see if you get the same error. There can be weirdness with loadpaths on current versions of g.r.s., but that is cleared up in the 1.0 branch (in progress right now).

@dgrebb
Copy link
Author

dgrebb commented Oct 31, 2014

That's really strange. Thanks for pointing me in the right direction, Sass throws the same error:

sass --update /var/folders/gp/f9w2t1zs4mb33vcshf1t8r3r0000gp/T/gulp-ruby-sass:/var/folders/gp/f9w2t1zs4mb33vcshf1t8r3r0000gp/T/gulp-ruby-sass/_14139e58-9ebe-4c0f-beca-73a65bb01ce9 --load-path src/scss

error /Users/dgrebb/Projects/tbi-dev-utils/development-standards/css/sass-template/src/scss/_utilities.scss (Line 13: Undefined variable: "$font-url--typekit".)

I'll keep digging. Sorry for wasting your time :)

@dgrebb dgrebb closed this as completed Oct 31, 2014
@robwierzbowski
Copy link
Contributor

No prob.

@UltCombo
Copy link
Contributor

UltCombo commented Nov 1, 2014

@dgrebb Sass does not support @import inside conditionals, imports must be statically analyzable in order to build the dependency tree for Sass's watch mode. See:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants