sbt-web-scalajs icon indicating copy to clipboard operation
sbt-web-scalajs copied to clipboard

Can't set scalaJSStage for configurations other than Global

Open ianknowles opened this issue 4 years ago • 2 comments

My project structure is mostly based on https://github.com/vmunier/play-scalajs.g8

The current suggestion there is to run packaging with sbt 'set Global / scalaJSStage := FullOptStage' Universal/packageBin this is ok as a workaround but obviously not ideal compared to being able to set Universal / scalaJSStage := FullOptStage in build.sbt so that fast opt is the default behaviour and only native packaging configs and tasks use full opt. I'm a little unsure if this setting would go in server or client, i'm guessing client would be preferable in case someone really wants multiple client projects with different opt settings.

I tried looking over the plugin but submitting a PR for it is a little beyond my current knowledge, please consider this enhancement request.

ianknowles avatar Aug 07 '21 12:08 ianknowles

changing ScalaJSStageTasks.scala line 11 from scalaJSStage.value match { to configuration.value / scalaJSStage.value match { might be all it needs?

ianknowles avatar Aug 07 '21 12:08 ianknowles

I tried to make it... but sbt has to much magic. :(.

def onScalaJSStage[A](onFastOpt: => Initialize[A], onFullOpt: => Initialize[A]): Initialize[A] =
    Def.settingDyn {
     val cog = configuration.value
      Def.settingDyn {
        (ThisBuild / cog / scalaJSStage).value match {
          case Stage.FastOpt => onFastOpt
          case Stage.FullOpt => onFullOpt
        }
      }
    }

It could be made, but still Universal:packageBin will compile js-project with Compile configuration.

scalway avatar Dec 10 '21 15:12 scalway