Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import LESS file only for one page

Tags:

css

less

I have main all.less file, where I'm including all other less files

e.g.

@import "scaffolding.less";
@import "type.less";
@import "code.less";
@import "grid.less";
@import "homepage.less";

So my question is.

Is it possible to get"homepage.less" only in homepage (importing it in all.less).

Please Note that I don't want to attach it directly in the html file.

Thanks

like image 437
FrontDev Avatar asked Sep 27 '22 23:09

FrontDev


1 Answers

On your homepage use:

<body class="homepage">

And then in your Less files:

.homepage {
  @import "homepage.less";
}

The above still compiles all your code in a single file. Your compiled CSS code will have a larger number of bytes, but you can cache the same file for all your pages.

like image 118
Bass Jobsen Avatar answered Oct 03 '22 01:10

Bass Jobsen