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!