0

I have a bunch of variables defined in _variables.scss. I don't want to import the whole file as it has some dependencies. I just want to import one of the variable from that file into another scss file.

Is it possible?

Use Case

I have two sets of scss files. Both have independent compilation flow. For one set, I have defined bunch of needed variables in _variables.scss. I need all these variables to compile the first set of scss files. Now there is second set of scss files, which need very few of the above defined variables.At present, I duplicated those few variables into _variables2.scss and imported it.

infused
  • 24,000
  • 13
  • 68
  • 78
Kvk
  • 522
  • 5
  • 15
  • It's unclear what you're trying to do. If you're using SASS to compile something like Bootstrap, it's going to need everything in _variables.scss to compile correctly. So what do you mean you want to just import one variable? How would you be using that? Because you can certainly just create a file like _myvariables.scss with just that one variable and include that. But as I mentioned, that wouldn't help if you're trying to compile all of Bootstrap. – manishie Sep 10 '14 at 19:52
  • Thanks for the comment manishie. Yeah I am already using the way you suggested, creating a new scss file with few needed variables. just wanted to find out if there is any way to do that. BTW it is not for bootstrap, just for the compilation of my custom scss files. Exact case is updated in the question. – Kvk Sep 11 '14 at 03:57
  • So it sounds like you've got it figured out? Just copy your few variables into the new file, right? So then what's the question? – manishie Sep 11 '14 at 04:04
  • Rather than duplicating the variables in two files, Can I import just the needed ones from a file. – Kvk Sep 11 '14 at 04:06
  • The real questions are: why do you have dependencies in your variables file? Or maybe you should break that file up so that you can import just the variables needed for a given module. – steveax Sep 11 '14 at 04:49

1 Answers1

0

You can do:

_shared_variables.scss:

// shared variables here

_variables_one.scss

@import "_shared_variables";
// all variables unique to the first sass file here

sass_one.scss

@import "_variables_one.scss";
// other sass one scss here

sass_two.scss

@import "_shared_scss";
// other sass two scss here
manishie
  • 5,302
  • 1
  • 20
  • 21
  • :) good one. I think it is not possible what I am expecting.. Anyways thanks for your answer. – Kvk Sep 11 '14 at 04:19