Search code examples
cssimportsassstylesheetexternal

Importing Sass stylesheets from an external directory


I have the following set up:

d:\modules\base - This is where my CSS framework (Inuit CSS) and site theme lives. The idea is for others to be able to use this as an import into their sites main style.scss and write their own styles on top of this.

d:\sites\my-site - As described above, I will import the module\base into my site.

To do this I use

@import "D:\modules\base\style";

Which works... But for other developers, their module mite be on a different drive, or have a different folder structure. So I was wondering if there was any way to do the following:

@import "$module-path\style";

Then they could set their module path themselves in a config file or something similar.

I appreciate there may be other methods to make this easier, e.g. having it all in the same folder, but would be interested if there was a solution to this method.

Thanks


Solution

  • I managed to get around this by making a directory link in d:\sites\my-site

    in CMD, type

    mklink /D my-link-name D:\modules\base\stylesheets
    

    this creates a link in the directory your in called "my-link-name" and points it to the module.

    Then I just include this in my sites style.scss like so:

    @import "my-link-name\style";