I want to compile the less file in public folder of expressjs application.
Dependencies which I am using are
"devDependencies": {
"ejs": "^2.3.1",
"express": "^4.10.6",
"mysql": "^2.5.4"
},
"dependencies": {
"less": "^2.5.1",
"less-middleware": "^2.0.1"
}
Content in styles.less file
header {
background-image: url('../img/bg.png');
height: 380px;
input#searchBox {
width: 100%;
height: 70px;
}
}
Server file looks like below
var express = require('express'); // call express
var app = express(); // define our app using express
app.use(require('less-middleware')('public'));
// Public folder
app.use(express.static('public'));
The less file is not modified while running it on server.
Remote Address:127.0.0.1:3000
Request URL:http://localhost:3000/css/styles.less
Request Method:GET
Status Code:304 Not Modified
What is the error here.
Directory structure:
Edit:
header {
background-image: url('../img/bg.png');
height: 380px;
#cloud-tag span {
color: #fff;
font-weight: 800;
letter-spacing: 2px;
}
#cloud-tag_word_0 {
font-size: 100px !important;
}
}
I added this css in less file and it is being sent to browser in same format without being compiled.
Less (sometimes stylized as LESS) is one of the dynamic style sheet languages that can be compiled into Cascading Style Sheets (CSS), or can run on the server-side and client-side.
Less (which stands for Leaner Style Sheets) is a backwards-compatible language extension for CSS. This is the official documentation for Less, the language and Less. js, the JavaScript tool that converts your Less styles to CSS styles. Because Less looks just like CSS, learning it is a breeze.
Create a stylesheet with . less extension and link it in your document using the rel="stylesheet/less" attribute. You are all set and can compose styles within the . less .
You must request the css file, not the less file, in your case http://localhost:3000/css/styles.css
not http://localhost:3000/css/styles.less
.
The middleware will compile the less file to the one you requested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With