Universally Register a Script/Style

Hey all,

Currently our Yii 1.1 application is a very module-heavy setup - aside from the very basic necessity pages (like login), virtually everything is using modules. Because of this, our:




functions for ‘core’ files (not necessarily Yii core scripts, but things like main.scss, basically anything that needs to be loaded on every single page) are happening in our main layout file.

This has worked for us until now, however we are about to start a big push to move everything over to SCSS. These exist on a module level just like everything else, so if there’s a SCSS file that is required for an entire module, we are registering it in the module file. BUT: since Yii technically reaches the module file before it reaches the main view layout, the end result is that the more modular and specific SCSS files are being loaded BEFORE the ‘core’ SCSS files that are defining colours, numbers, etc. So none of the SCSS variables are working.

This obviously won’t work for us, and the most obvious solution that strikes me is that the core SCSS registrations need to be moved out the main layout file, to somewhere else (they really shouldn’t be in there anyway). Thing is, I’m not sure where to move them? Needing to manually register main.scss on every single module will be a chore and susceptible to failure if we change something and then need to go update every single module (more than a dozen, more than three dozen if you count the multiple live installs of this application).

So: how and where, can I register a sass file (or a script, or a css file) ‘universally’? Across the entire site, whether it be in a module or in the application root. in essence, I need to be able to say ‘these files will load on every page, every time, before anything else does’.

Any thoughts or advice?

EDIT: SO I found a solution, that being to actually import the _colors.scss file, because I’m a simpleton and wasn’t doing it.

However, I’d still like to know if there’s a better solution here, than dropping a bunch of Script/CSS/SCSS registrations into a layout file.