<link rel="stylesheet/less" type="text/css" href="global.less">
<script src="js/less.min.js" type="text/javascript"></script>
In the above global.less
had been opened with a XMLHttpRequest
, see also How to open a local disk file with Javascript?.
Files that you want to import in global.less
with the @import
directive can be places in the same directory global.less
. Notice that this directory should be accessible by the browsers. Files can also be placed in a sub directory or a directory relative to the directory of global.less
.
See also http://lesscss.org/usage/#using-less-in-the-browser you can set the option for the less.js compiler by defining a global less
object before calling the compiler. This enables you to set the include_path
and rootpath
, the include_path
can be used to define where to search for the imports whilst the rootpath
re-write relative urls to the base less file.
NB For your live preview you should call less.refreshStyles()
/ less.modifyVars
, see ModifyVars issue when trying to change variables one by one unless reloading (and recompiling) is allowed.