Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why LESS css does not work on localhost

According to this tutorial my less code should work but it doesn't.

Can you please help me to get my less css to work.

Right now it does not working - Page loads with no applied styles. What am I doing wrong?

The error is:

FileError: 'localhost:1/styles.less' wasn't found (404) in styles.less

But it is there in the root?

HTML

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title></title>
    <link rel="stylesheet/less" type="text/css" href="styles.less">
    <script src="_/script/less-1.4.1.min.js" type="text/javascript"></script>

</head>

<body>

    <div id="header">test</div>

    <h2>test h2</h2>

</body>

</html>

styles.less

LESS

@color: red;

#header {
    color: @color;
}
h2 {
    color: @color;
}
like image 624
Hello-World Avatar asked Nov 27 '22 17:11

Hello-World


2 Answers

If you are using IIS you have to add a ".less" extension to MIME type within IIS manager. when you add a new MIMI, enter ".less" as the extension and "text/css" as the MIME type.

like image 198
akif1 Avatar answered Dec 09 '22 20:12

akif1


Assuming the website is hosted over iis express, Open the file

C:\Users\\Documents\IISExpress\config\applicationhost.config

and search for the tag
<staticContent lockAttributes="isDocFooterFileName">

and add the .less MIME as below

<mimeMap fileExtension=".latex" mimeType="application/x-latex" />

<mimeMap fileExtension=".less" mimeType="text/css" />

<mimeMap fileExtension=".lit" mimeType="application/x-ms-reader" />

like image 29
AKS Avatar answered Dec 09 '22 20:12

AKS