Dotless failing to compile ; in Bootstrap 3 less source

Deadly 提交于 2019-12-18 14:09:09

问题


I use dotless 1.3.1.0 compiling less-files. This worked fine with bootstrap 2.x, but after switching to bootstrap 3.0.0 (downloaded the source from here: http://getbootstrap.com/getting-started/), I suddenly get this error:

Expected ')' but found ' ' on line 47 in file 'mixins.less': [46]: // Sizing shortcuts [47]: .size(@width; @height) { ------------^ [48]: width: @width;

Seems that having a ; as seperator between parameters is not valid less. The original source in the mixins.less looks like this:

...
// Sizing shortcuts
.size(@width; @height) {
  width: @width;
  height: @height;
}
...

Do I have to use an updated less compiler? Or did bootstrap release buggy less source?

UPDATE 1: I can see, that a pull request for dotless exists, fixing the problem with ;

https://github.com/dotless/dotless/pulls "Fixes for ; not supported in mixin parameter lists #319 #320"

I will go using the css files until this has been fixed in dotless.


回答1:


One of my colleagues that uses dotless has had a few fixes for Bootstrap 3 issues merged. Apparently Bootstrap3 will now compile with the latest code :)

https://github.com/dotless/dotless/commits/master

I expect an updated NuGet package will be available soon (based on this tweet)




回答2:


If you check out bootstrap's getting started page, you'll find that they state:

LESS compilation

If you download the original files, you need to compile Bootstrap's LESS files into usable CSS. To do that, Bootstrap only officially supports Recess, Twitter's CSS hinter built on top of less.js.

Though not using dotless, I followed a similar path that you did using lessc, and then found that using recess resolved my issue. Perhaps using recess would be an option for you too?

As an example, I have a file called tmpfl.less with the following contents:

@import "mixins.less";
@import "variables.less";


.wrapper {
  .make-row();
}
.content-main {
  .make-lg-column(8);
}
.content-secondary {
  .make-lg-column(3);
  .make-lg-column-offset(1);
}

If I run lessc on it, I get the following result:

lessc tmpfl.less 
NameError: .size is undefined in mixins.less:47:0
46 // Sizing shortcuts
47 .size(@width; @height) {
48   width: @width;

Now, I successfully use recess as follows:

recess --compile tmpfl.less > tmpfl.css

Update:

In order to utilize Recess in a .Net environment, specifically in Visual Studio, one can follow these instructions for details on installing. Those instructions provide an overview, but perhaps leave out some details on getting Node.js installed. Microsoft has some brief words about it and they link to a GitHub project which might be helpful depending on your version of Visual Studio.

If you don't go down the Node.js-in-Visual Studio route, then really the main goal is to have Node.js installed somewhere, and then ultimately npm, the package manager for Node.js so you can install Recess. That can be achieved on Windows by going to the Node.js download, and installing the Windows version. Installing npm is highlighted in this stackoverflow discussion. Once installed, you just need to run npm to install Recess as follows:

npm install recess -g

That is also discussed in the first link of this update.




回答3:


After spending hours on getting this to work myself i found that dotless is quite useless at this time.

but here is where you can impliment Less and Bootstrap 3 Less in your mvc ASP.Net Project

http://www.tomdupont.net/2013/10/bootstrap-3-less-bundling-and-aspnet-mvc.html?showComment=1386250367416#c1439130135847828203

This guy just won an internets in my book and if you can track down his stack exchange account for me let me know.




回答4:


I have put together an httphandler which will compile less using lessjs.

It's more of a proof of concept than production quality code, however it may be useful for some people as a starting point.

You can find the source here:

https://bitbucket.org/martinbooth/clearscriptless

In case anyone is interested in trying to do this using jurassic, you can find my attempt here:

https://bitbucket.org/martinbooth/jurassicless

I don't recommend Jurassic for this because

  • it required a few bug fixes to the library which are not currently integrated into the main project My changes are now in the master branch of Jurassic so this is no longer an issue (though the latest release does not currently include them)
  • it is very slow, hence the reason I tried clearscript


来源:https://stackoverflow.com/questions/18528432/dotless-failing-to-compile-in-bootstrap-3-less-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!