0

I have the following file structure:

  • main.less
  • modules
    • colors.less
    • header.less
    • footer.less
    • video_player.less
    • reset.less
    • base.less

colors.less looks like:

@brand-primary-color: orange;
@brand-secondary-color: grey;

I would like to import colors.less in main.less, and have the variables used globally throughout the less files.

Creating themes would look something like this:

  • brand-1.less

    @import "themes/brand-1-colors.less"

  • brqand-2.less

    @import "themes/brand-2-colors.less"

  • brand-3.less

    @import "themes/brand-3-colors.less"

  • [...]


Can't find any way to do this!

The only method that seems to work is to import the colors.less file within each less sub-file. This makes creating themes a bit tedious...


Any ideas? :) Thanks guys!

1 Answer 1

2

Presuming main.less has CSS in it, all you have to do is create a file where you'd import all other less files. The file structure would look like:

  • final.less
    • modules
      • main.less
      • colors.less
      • header.less
      • footer.less
      • video_player.less
      • reset.less
      • base.less

After compiled, the final.css would be the CSS file containing everything. The final.less would look like:

@import "main.less";
@import "colors.less";
@import "header.less";
@import "footer.less";
@import "video-player.less";
@import "reset.less";
@import "reset.less";

Last but not least, you should compile only final.less.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.