19

When working with lesscss I would like to join two or three .less files into one super css file.

I know that you can do it using some little ruby magic, but I would like to know if there is something simple in the less engine?

Dejan
  • 731
  • 1
  • 6
  • 17

2 Answers2

24

You can use import, similar to how you can in a regular CSS file.

@import "reset";
@import "config";
@import "header";
@import "forms";

Taken from this SO post. It's also mentioned in the "Importing" section of the Less Documentation.

Community
  • 1
  • 1
Dan Herbert
  • 99,428
  • 48
  • 189
  • 219
12

Simple solution:

  1. Create a main.less file and open it (name it as you like)

  2. Import your other css and less files via @import

    • @import "filename.less"; for less files

    • @import "filename.css"; for css files.

  3. Compile your main.less file and just include this main.css in your site

  4. Smile :)

Bijan
  • 25,559
  • 8
  • 79
  • 71
  • 3
    This resulting css files, has import statements for each of the css files. The css is not merged, The files remain separated. – Mick Nov 17 '15 at 23:25
  • @Mick if you use a tool like lessc (`lessc main.less main.css`) it will result only in one file – ellockie Sep 18 '18 at 11:23