stratigos

stratigos

How to Specify Order of Local CSS / SCSS Files with Brunch?

Hello all, and thanks for this great forum!

I am learning Phoenix 1.3, and having trouble specifying the order of my local SCSS files. The specific problem I am having is that I want a “colors.scss” file to store all my application’s color variables, and need this loaded first before any of my other component, typographic, or general style files.

So I am stuck getting “brunch error…” messages, where it cant find $color-var specified in my colors.scss file. It works fine when I shove everything into one file.

Files in my assets/css/SUBDIR/*.scss location are seemily loaded in “random” order. My colors.scss file is not loaded in an expected order, and files which depend on its variables are loaded first (even if theyre in lower order, alphabetically speaking).

I have tried specifying order in my brunch config, as per the recommendations. This seems to have zero effect on the order. Furthermore, it seems specific to how files are concatenated in the web/static/css/ location, which does not help me. I need to order the files in my assets/css/ dir.

Finally, Ive also tried to specify the order in my css/app.scss file itself, via import statements. This seems to have zero effect - the color variables are simply not found in files specified later.

Upon further inspection, it seems like I need to declare the variables in every file - if I declare them in the first file that claims its missing the variable, another file is simply missing the same one. I tried declaring all my SASS variables in css/app.scss, and the subsequent files in the css/SUBDIR/ location are still missing the vars. I come from a Ruby on Rails background, so I could be a bit naive as to how CSS/SCSS files are loaded and compiled with Phoenix.

What is the convention for organizing SCSS files in Phoenix > 1.3.0, and how can I keep variables in certain files, and load other files later?

Thanks in advance! :smiley:

Most Liked

amnu3387

amnu3387

I’m not sure if there’s a convention, and I haven’t used brunch in a while but:

Assuming you’re concatenating to a app.scss file which includes the following lines:

@import "colors";
@import "custom";

Declarations in custom.scss should be able to access variables declared in colors.scss . Because sass is compiled, if you then have another file extra.scss, even if you’re using both app.scss and extra.scss in the same page, extra won’t have access to the vars declared in colors unless you make an import statement in extra as well, or make extra be another import in app.scss

stratigos

stratigos

Nice analogy!

Well thanks for testing this out for me. I unfortunately need to stick with brunch for the time being. Webpack is a whole other hell, although arguably more familiar to me ;).

Im going to stick these import statements in “all of the things” for now, and figure this out later. Lost about 6 hours trying to figure out something so simple today!

amnu3387

amnu3387

In the end I found webpack to be easier to config - I did loose some time setting it up, but from then on it hasn’t given me any problems (and it’s doing way more than brunch did).

But probably brunch should handle this fine, so I imagine there’s something else missing.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement