2

I have a web application with pure JS frontend and Scala backend. I would like to use Grunt in my build pipeline to process src/main/webapp into target dist/webapp dir with concatenated/minified js and html files, compiled sass sheets etc. I also want to preserve original JS and HTML files for local testing using container:start task, while the package task would build my WAR file with resources processed by Grunt. When I use following setting in SBT:

webappResources in Compile <<= baseDirectory { bd => Seq(bd / "dist" / "webapp") }

then I achieve the second goal - my WAR gets built using the webapp resources in dist/webapp. However, when using container:start during local development I get bound to the same directory. Is there any way to define different dirs for different purposes?

kciesielski
  • 1,178
  • 9
  • 18
  • How does the build configuration look like? Could you prepare a sample application to play with and publish it on github? I doubt I've got enough knowledge to develop one myself. – Jacek Laskowski Jan 09 '14 at 20:12

1 Answers1

1

xsbt-web-plugin supports SBT 0.13.1 so you can use the much-nicer syntax to define webappResources in the Compile scope:

webappResources in Compile := Seq(baseDirectory.value / "dist" / "webapp")

I might be mistaken, but webappResources alone would work, too.

webappResources := Seq(baseDirectory.value / "dist" / "webapp")

or even (unless you want to replace the original value not to append a value):

webappResources += baseDirectory.value / "dist" / "webapp"

As for the solution I'd use the following (untested) in build.sbt:

webappResources in package := Seq(baseDirectory.value / "dist" / "webapp")

and leave the default value for the webappResources setting for local development.

Read Scopes to learn more about "scoping" settings, i.e. setting different values for different axes.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Thanks, I am aware of simplified syntax of SBT 0.13 but switching from 0.12 is a different task, requiring some additional work which I left for later. I have tried using different values than `Compile` (``package``, `packageWar`, `packageBin`) but unfortunately it didn't do the job (I still get unprocessed resources in the WAR file). – kciesielski Jan 09 '14 at 06:55