Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can variables be used in import statements for Sass files?

Tags:

import

sass

In Less I can do something like this

@basePath:"../../some_crazy_project_path_to_repeat/less/"; @import "@{basePath}less.less"; 

So I tried to do the same thing in Sass

$basePath:"../../some_crazy_project_path_to_repeat/less/"; @import "${basePath}less.scss"; // Syntax error: File to import not found or unreadable: ${basePath}less.scss. 

and

@import "#{basePath}less.scss"; // Syntax error: File to import not found or unreadable: #{basePath}less.scss. 

Is there a way to do this in Sass?

like image 284
Shanimal Avatar asked Jul 11 '13 17:07

Shanimal


People also ask

Where do you declare variables in Sass?

Sass variables are only available at the level of nesting where they are defined. Will the color of the text inside a <p> tag be red or green? It will be red! The other definition, $myColor: green; is inside the <h1> rule, and will only be available there!

How do you access a variable in Sass?

The basic syntax for defining a variable is simple: Just use a $ before the variable name and treat its definition like a CSS rule: Sass Variable Syntax: $<variable name>:<value>; The following declares a variable named large-font.

How do I set variables in SCSS?

To create a SCSS variable: Navigate to Acquia Cohesion > Website settings > SCSS variables. Enter a variable name in the Variable name field. Enter a value in the Variable value field.


1 Answers

You can't use conditional stuff for imports in SASS.

Consider creating a Compass extension out of your project.

like image 188
Andrey Mikhaylov - lolmaus Avatar answered Sep 30 '22 07:09

Andrey Mikhaylov - lolmaus