问题
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?
回答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.
来源:https://stackoverflow.com/questions/20996993/how-to-have-different-webapp-resources-for-containerstart-and-package-tasks-in