0

I was wondering if there is a way to make a mixin globally accessible in sass. Below is a github link. I am using SMACSS standards for file structure.

https://github.com/sfp-justin/framework

If you look in resources/assets/scss/utilities/_mixins.scss you will see my mixins thus far. I import them into a master index file. app.scss has all of my main imports. I know I could just move the import for utilities to the top of the list and I would be able to gain access to that mixin, but I don't wanna depend on these items being in a specific order if possible. If you look in resources/assets/scss/layout/grid/_cell.scss you can see an import.

So is there a way to do the above, or you can point me in the right direction it would be appreciated.

justin.esders
  • 1,316
  • 4
  • 12
  • 28
  • Always put your variable and mixins first in the order of compiling. I use SMACSS as well and this is no problem. The variables and mixins are in the same directory as the app.scss file. having them in an order is just good practice – Brad Jul 20 '18 at 12:21
  • Ok. I must have just been overthinking it. I usually put everything in the correct order, I just didn't know if there was a way have them globally accessible or if I even should. Thanks for the help. – justin.esders Jul 20 '18 at 14:11
  • Puting them first makes them globally accessible to any file that comes after – Brad Jul 24 '18 at 01:32

1 Answers1

0

This would depend on your scss compiler. If it can be extended in this way or if you could perhaps extend it yourself through an open source mechanism. I'm not sure if any of them have this capability right now, but ideally you could just drop a custom scss file into a "Global" folder or something like that and it would be referenced any time the compiler runs.

Libsass lists the "sanctioned" compilers as:

https://github.com/sass/node-sass (Node.js)

https://github.com/sass/perl-libsass (Perl)

https://github.com/sass/libsass-python (Python)

https://github.com/wellington/go-libsass (Go)

https://github.com/sass/sassc-ruby (Ruby)

https://github.com/sass/libsass-net (C#)

https://github.com/medialize/sass.js (JS)

https://github.com/bit3/jsass (Java)

Read through docs of the one you're using to determine if it's possible.

Chad H
  • 584
  • 3
  • 11