I am trying to setup a Play framework 2.1.1 with Twitter Bootstrap 3 using the LESS files.
I've put the bootstrap LESS files into app\assets\stylesheets\bootstrap
.
I've update my project configuration (Build.scala
), in order to compile only the main bootstrap.less
file (importing the other files) :
val main = play.Project(appName, appVersion, appDependencies).settings(
lessEntryPoints <<= baseDirectory(customLessEntryPoints),
javascriptEntryPoints <<= baseDirectory(customJavascriptEntryPoints)
)
def customLessEntryPoints(base: File): PathFinder = (
(base / "app" / "assets" / "stylesheets" / "bootstrap" / "bootstrap.less") +++
(base / "app" / "assets" / "stylesheets" / "*.less")
)
def customJavascriptEntryPoints(base: File): PathFinder = (
(base / "app" / "assets" / "javascripts" * "*.js")
)
I can't manage to compile Bootstrap, I get the following :
Expected )
In ...\app\assets\stylesheets\bootstrap\mixins.less at line 0.
The problem seems to come from the mixin parameters separed by semicolons. When I replace these semicolons by commas it works.
Does the Play LESS compiler need commas ? Do I need to replace every semicolon by comma or can I configure Play LESS compiler ?
Thanks
EDIT :
There is an official issue here : https://github.com/playframework/playframework/issues/1423
It seems that i need to wait for an upgrade of Play with a new version of LESS compiler. I'll be using an external compiler meanwhile.
Here is a temporary solution posted by the guy mica16 from github:
1) I installed the plugin following the documentation: https://github.com/jmparsons/play-lessc (there's an error in the example shown => the command must be: npm install -g less
and not npm install -g lessc
).
2) In the plugins.sbt, I added these lines :
resolvers += "JMParsons Releases" at "http://jmparsons.github.io/releases/"
addSbtPlugin("com.jmparsons" % "play-lessc" % "0.0.8")
(make sure you separate them by a line jump)
3) I opened my build.scala and I inserted the lines specified by the plugins and add these:
def customLessEntryPoints(base: File): PathFinder =
(base / "app" / "assets" / "stylesheets" * "bootstrap.less") +++
(base / "app" / "assets" / "stylesheets" * "main.less") (main.less is my custom css)
For a reason I can't define (I don't even seek for it for now), you should place your bootstrap less files directly in the stylesheets root folder. Otherwise, I couldn't make those file compile.
4) I specified the html line concerning the css:
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/bootstrap.min.css")">
5) I run play run
and the whole worked.
Edit - As someone asked: is there a way to install lessc plugin without installing jsnode and npm?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With