This description works for a Play 2.2.x application.
At the root of the project exists package.json
. It describes that you want to install grunt-cli
, grunt-contrib-sass
, and grunt-contrib-watch
. You need to make sure you run npm install
to pick up these packages. You'll probably need to install grunt-cli
globally.
/gruntfile.js
describes what you want grunt to watch. This is my least favorite part, since I have to designate where I'd like the compiled files to go. Seems a bit brittle.
In /project/Grunt.scala
exists the hook which starts and stops grunt when you run the application.
A line needs to be added in build.sbt
to let play know about the run hook.
Then you can initiate play run
command and it should auto-compile on scss change.
For deployment, I have play installed on my server and initiate play start
. If this is your case, then you just need to remember to run grunt sass
beforehand.
I just wanna thank you! 🎉 Everything seems to work so well so far except the part with the compiled CSS files. First of all I want to get rid of the whole play-sass plugin. Now I got my application running on production server and the app is working fine which I first prepare locally with the stage task.
You wrote that the specific destination path
target/scala-2.10/classes/public/
is a bit brittle. Let me show you how I develop locally$ grunt sass
and this compiles it to the brittle directory$ activator stage
to prepare the whole package which I'll deploy on my production environmentDo you have an idea, why? Probably it's a thing with the asset pipeline of Play but I'm sure there's a way to serve static CSS files. Do you know how? In addition to this I'd like to minify my CSS files for production but this is an easy thing with Grunt. 😉
Let me know if you have a clue and one more time, thank you so much for this gist 👍