2

I'm using sbt-web, and I'd like to only uglify js files for production (saves compile time while developing). However, when I run:

sbt prod:run

I get the same result as

sbt run

That is, prod:run doesn't seem to pickup the pipelineStages in prod scoped setting, below.

I'm certain that I am mis-understanding how this all works, and am hoping for some clarity and correct usage. I've read http://www.scala-sbt.org/0.13/tutorial/Scopes.html and every similar post on SO but the lightbulb hasn't turned on yet. I'm OK if there is a better way to do it, but because I'm in learning mode, I'd still like to know the reasons behind why this doesn't work.

Here is the full ./build.sbt file:

organization  := "com.test123.spray"

version       := "0.1"

scalaVersion  := "2.11.6"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  val akkaV = "2.3.9"
  val sprayV = "1.3.3"
  Seq(
    "io.spray"            %%  "spray-can"     % sprayV,
    "io.spray"            %%  "spray-routing" % sprayV,
    "io.spray"            %%  "spray-testkit" % sprayV  % "test",
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test",
    // client side dependencies
    "org.webjars" % "jquery" % "2.1.4",
    "org.webjars" % "uikit" % "2.24.2"
  )
}

// sbt-web pipeline for combining, minifying, etc... client-side files
// see plugins.sbt for sbt dependencies that provide this capability.
lazy val root = (project.in(file(".")))
    .enablePlugins(SbtWeb)
    .configs(prod)

lazy val prod = config("prod") extend(Compile) describedAs("Production")

Concat.groups := Seq(
  "app.js" -> group(Seq("js/b.js", "javas/a.js")),
  "vendors.js" -> group(Seq("lib/jquery/jquery.js", "lib/uikit/js/uikit.js"))
)

pipelineStages := Seq(concat, gzip)

// run uglify in prod only
pipelineStages in prod := Seq(concat, uglify, gzip)

(managedClasspath in Runtime) += (packageBin in Assets).value
l p
  • 528
  • 1
  • 7
  • 17
  • Extending a configuration doesn't quite work that way, and you will have to reimplement the tasks reading the settings from the configuration you want. – pfn Jan 02 '16 at 06:34

0 Answers0