Exploring sbt/play configuration is a new challenge for me. Working with play 2.3.8 to host my javascript application, my project utilizes:
.enablePlugins(SbtWeb)
.enablePlugins(play.PlayScala)
.settings(
...
libraryDependencies ++= WebDependancies :+ evobufAkka,
pipelineStages in Assets := Seq(closure, digest),
...
// Certain closure compiler settings
)
Currently, the project utilizes closure compiler to compress the code, among other things. However, I am considering a change. Instead of relying on closure compiler, I am interested in utilizing simple npm packages. Understanding that sbt has the capability to execute shell tasks, my motive is to segregate the server and frontend responsibilities, delegating frontend tasks like less, uglify, and fingerprinting to a JavaScript tool like node. While sbt-web is an option, I prefer to steer clear of it if possible. My envisioned process is as follows: 1. Launch sbt and load my project 2. Execute compile: - sbt would trigger my npm tasks, resulting in a build.js file to be served by the play framework from /public directory or a similar location. 3. Ideally, I would like the ability to conduct unit tests in a separate process.
Regarding npm setup, I am contemplating placing the package.json file in my project/public
folder, unless it is more suitable to position it within project/app/assets
.
Is such a setup feasible?
Update 8/8/2015
After conducting some research, I discovered information about external processes. Based on a sample, I devised:
lazy val npmBuildTask = taskKey<Unit>("Execute the npm build command to build the ui")
npmBuildTask := {
"cd public/ && npm install" !
}
My concern now is how to integrate this task into the compile process?