Reputation: 1166
LESS compilation in my fresh Play 2 install is genuinely slow. Even after placing an '_' on files that do not need direct compilation, a page refresh after a LESS edit takes ~8 seconds to complete. This is compared to a local compile using Codekit which takes less than a second.
Any suggestions on speeding up this process? Is it worth filing a bug against Play to have this looked at?
Here are details on my file sizes: My LESS setup is very simple. _reset.less (.5k) _desktop.less (13k), _tablet.less (10k), _mobile.less (8k), _sprites.less (25k) files. An all.less (.3k) file that puts it all together. That's it. The resulting css file is 53k.
Upvotes: 10
Views: 1433
Reputation: 2435
From Play Framework 2.3, you can use node.js as default JavaScript engine, which is used for less compilation, js lint, CoffeeScript etc..
Download and install node.js (https://nodejs.org) library and put
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
to build.sbt.
Upvotes: 2
Reputation: 1127
This will dramatically reduce the compilation time:
export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node"
It makes Play use Node instead of Rhino when running JavaScript.
Upvotes: 2
Reputation: 26211
I did a write-up of a small investigation into this problem. You can find it here.
Bottom line: I get faster performance by switching to Sass. It's not hard to do. Use the Play-Sass SBT plugin and, if you're using Bootstrap, use the SASS Bootstrap files from the sass-twitter-bootstrap project.
Precompiling your LESS files via the lessc
command is another solution, and it's quite fast.
Assuming your project uses Bootstrap, using a precompiled Bootstrap, rather than the Bootstrap LESS files, is also a big win, because the Play LESS compiler recompiles all LESS files when one of them changes, and Bootstrap is rather large. But, for some of us, using a precompiled Bootstrap is inconvenient...
Using Play 2.0's Rhino-based, on-demand LESS compilation is the slowest option. Pig-slow, in fact. And ignore my comment about incrementalAssetsCompilation
. It's documented, but it does not appear to be in the 2.0.x code base.
EDIT (22 May, 2013) Jonathan Parsons has put together a play-lessc plugin that uses the lessc
command to compile LESS files. It can dramatically decrease LESS compilation times in a Play project. See https://github.com/jmparsons/play-lessc
Upvotes: 8