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! ![]()
Most Liked
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
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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









