Why LESS css does not work on localhost

According to this tutorial, my smaller code should work, but it is not.

Can you please help me make me work less css.

Now it does not work - loading a page without applying styles. What am I doing wrong?

Error:

FileError: "localhost: 1 / styles.less" not found (404) in styles.less

But is it at 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; } 
+4
source share
7 answers

Thank you for all your help - it turns out that my local host was not a mime.less type

+4
source

If you are using IIS, you need to add the extension โ€œ.lessโ€ to the MIME type in IIS Manager. when you add a new MIMI, enter ".less" as the extension and "text / css" as the MIME type.

+11
source

Assuming the website is hosted on top of iis express, open the file

C: \ Users \\ Documents \ IISExpress \ Config \ ApplicationHost.config

and tag search
<staticContent lockAttributes="isDocFooterFileName">

and add MIME unchanged as below

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

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

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

+11
source

I also ran into this problem.

None of the above fixes worked, however I managed to fix it when I checked access to the folder where the less.css file was saved.

Adding the IUSR user for read rights to the folder allowed the file to be distributed correctly.

+1
source

It looks like the original location of your file is incorrect.

 <script src="_/script/less-1.4.1.min.js" type="text/javascript"></script> 

I have never seen a "_" be used for navigation. In fact, if the script folder is in the same directory as the html page, then

 <script src="script/less-1.4.1.min.js" type="text/javascript"></script> 

should be enough to have a working js file on your page.

0
source

I am using IIS 7.5, but this may be the same for other versions of IIS:

In IIS, the mime type should be added for less. But in my case, I have to add it to the โ€œDefault Websiteโ€ using IIS Manager, and not to my application, in order to be able to download fewer files from the browser.

0
source

In my case, I already had mimeType for .less on ISS, so I checked the Web.config file on my website and deleted the following line because it caused duplication:

0
source

Source: https://habr.com/ru/post/1495304/


All Articles