Page MenuHomePhabricator

MediaWiki LESS files are incompatible with lessc
Closed, ResolvedPublic


I tried to compile vector.less using lessc 1.4.2 (LESS Compiler) [JavaScript]:

$ lessc --include-path=/home/spage/projects/core/resources/mediawiki.less/ resources/mediawiki.ui/vector.less

fails with

FileError: 'mediawiki.mixins' wasn't found in .../resources/mediawiki.ui/components/default/buttons.less on line 1, column 1:
1 @import "mediawiki.mixins";

It seems lessc requires you include the extension when importing files from the include path. If I change the line in buttons.less to

@import "mediawiki.mixins.less"

then lessc fails with
ParseError: Unrecognised input in .../resources/mediawiki.less/mediawiki.mixins.less on line 15, column 18:

15 background-image: url(@url)!ie;

lessc doesn't like the !ie. We actually use this in e.g. mediawiki.action.view.postEdit. Maybe it needs to be quoted or escaped in some way.

Our PHP compiler in includes/lib/ is obviously different code than the nodejs implementation, but we should avoid gratuitous incompatibilities.

An alternative to using lessc is to use ResourceLoader to generate the CSS, e.g.* , and save the resulting file.

Version: 1.23.0
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 3:03 AM
bzimport set Reference to bz62300.
bzimport added a subscriber: Unknown Object (MLST).
Spage created this task.Mar 6 2014, 2:17 AM

Two reasons this fails:

  1. Configuration

You're comparing a run of php-lessc having configuration with node-lessc having no configuration. See documentation for lessc for how to set e.g. import path.

  1. Hooks

Lessc is a dynamic parser that allows variables and hook functions to be registered. This is the case both in the node as well as the php implementation. However as these variables and hook functions are declared in the backend language (not in less syntax itself) they will inherently not be usable by other interpreters.

Classifying as low priority enhancement (not a bug) as there should be no expectation that running it on another parser would work or what the use case of that would be.

There are other incompatibilities besides the inability for another language to interpret the variables and hook functions, but those are upstream features / bugs in the php or js implementation.

matmarex closed this task as Resolved.Oct 27 2015, 10:17 PM
matmarex claimed this task.

We no longer use !ie, since it was also incompatible with the oyejorge/less.php parser that we switched to per T112035.