我正在使用sbt-web,我只想uglify js文件进行生产(在开发时节省编译时间)。但是,当我跑:
sbt prod:run
我得到与
相同的结果sbt run
也就是说,prod:run
似乎没有获取下面的pipelineStages in prod
作用域设置。
我确信我错误地理解这一切是如何工作的,并希望有一些清晰和正确的用法。我已经阅读了http://www.scala-sbt.org/0.13/tutorial/Scopes.html以及SO上的每个类似帖子,但是灯泡尚未打开。我很好,如果有更好的方法,但因为我处于学习模式,我仍然想知道为什么这背后不起作用的原因。
这是完整的./build.sbt文件:
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