How to enable less.js using require.js

All .js files on the site are included using require.js. How to enable less.js using require.js? When I enable it with a script tag, it doesn't work less.

+3
source share
3 answers

For required

requires a plugin with the requirement

https://github.com/guybedford/require-less

+4
source

You probably shouldn't do this. You always put your CSS at the very top of your HTML document, as far as possible, on the given one. When you use LESS instead of CSS, place both the LESS file and the LESS.js file as high as you can in the document. Correctly, using LESS in the browser, you have 2 files that you need to serve before loading the page.

, , , CSS LESS , . , , LESS.

, Less Parser (-) Less.App(mac) ( ). , .

, Ant Maven Asual LESS Jar (github).

, .NET IIS (dotlesscss.org), php (leafo.com/lessphp), NodeJS, Java ( ), ColdFusion .. .. github.com .

+1

In my case, I am doing something like ...

// Remove old/minify css & Add style.less in <head>
$('link[href*="style.min.css"]').remove();
$('head').append($('<link rel="stylesheet/less" type="text/css"/>').attr('href','style.less'));
less = {env:'development',poll:3000,logLevel:1};

// So run here
require(['less'],function(less){
   less.watch();
});

This is just an example + tested in my case

+1
source

All Articles