I’m currently building a website using the Play! 2.0 (2.1-RC2) framework and Scala. I have a bunch of “static” html files that define my views used by AngularJS (I’d much rather use Jade, but I can’t seem to find a way to get Jade to be precompiled with Play/Scala.. which makes sense, since Jade templates usually aren’t static).
What makes the most sense for me, as a developer, and my project’s structure is to have these html files in the same place as my coffee and less files (/assets/*). I understand that Play wants me to put them in my public folder, however I have a hard time with that. To me, the public folder should be for libraries and generated files.
What I’d like to do is somehow get Play to copy the html files in /assets/views to /public/views as part of the build. How could I accomplish this?
Many thanks in advance!
I was able to figure out how to do this in a Scalatra test project, so I just need to modify the following code to adapt it to Play’s folder structure. It does, however, work. What it does is defines a new sbt “Plugin” and, at compile time, copies any files in /src/main/html to /resource_managed/main/views.
Hopefully someone will find this useful!
Now, in our build.sbt file we can add
And the views are now copied at compile time 🙂
There is probably an easier way to do this, I’m sure, but this works for me and was able to let me get an understanding of building a sbt plugin! 😛