1

I'm working on an sbt-web plugin that works as a source file task. It seems to be working decently with one huge caveat, it runs twice for every pass. I can't figure out why, or even exactly how to debug what's going on, so any help in either regard would be greatly appreciated. What I do know is that if I invoke "activator run," then load a page, my plugin gets invoked 2x, while all of the others, such as JSHint and Stylus, only get invoked once.

My plugin is actually doing a lot less than those other plugins, so I suspect there is some smallish piece of configuration that I'm missing. Does anybody know what might cause a plugin to be invoked twice, or what someone needs to do to prevent that? Here's a snippet of the code:

object Import {
  val webpack = TaskKey[Seq[File]]("webpack", "Run the webpack module bundler.")
}

object SbtWebpack extends AutoPlugin {

  override def requires = SbtJsTask
  override def trigger = AllRequirements

  val autoImport = Import

  import com.typesafe.sbt.jse.SbtJsEngine.autoImport.JsEngineKeys._
  import com.typesafe.sbt.jse.SbtJsTask.autoImport.JsTaskKeys._
  import com.typesafe.sbt.web.Import.WebKeys._
  import com.typesafe.sbt.web.SbtWeb.autoImport._

  override def projectSettings: Seq[Setting[_]] = Seq(
    includeFilter in webpack := "*.js" || "*.jsx",
    (nodeModuleDirectories in webpack in Plugin) += baseDirectory.value / "node_modules",
    webpack in Assets := runWebpack(Assets).dependsOn(webJarsNodeModules in Plugin).value,
    resourceGenerators in Assets <+= webpack in Assets,
    resourceManaged in webpack in Assets := webTarget.value / webpack.key.label,
    resourceDirectories in Assets += (resourceManaged in webpack in Assets).value
  )

  private def runWebpack(config: Configuration): Def.Initialize[Task[Seq[File]]] = Def.task {
    ... doing stuff ...
  }
}

Thanks in advance!

Joe
  • 1,723
  • 2
  • 14
  • 16
  • 1
    When I see "twice" and Play, my first guess is that it's related to [playframework/playframework#2237](https://github.com/playframework/playframework/pull/2237). There may be some resolution with 0.13.8 with [sbt/sbt#1714](https://github.com/sbt/sbt/pull/1714) change. Someone who's more familiar with Play can provide an actual answer. – Eugene Yokota Feb 18 '15 at 20:49

0 Answers0