sbtscala.js

How to import `%%%` in `Build.scala` in a scalajs project?


We can easily use %%% in a build.sbt in a scalajs project, like:

libraryDependencies +=
  "com.lihaoyi" %%% "utest" % "0.3.0" % "test"

(live demo: https://github.com/scala-js/scala-js-pickling/blob/master/build.sbt#L92)

But when I try to use project/Build.scala to write the same build file, it can't compile, and I've no idea how to import the %%%:

import org.scalajs.sbtplugin.cross.{CrossType, CrossProject}
import sbt._
import Keys._

object Build extends sbt.Build {

  lazy val crossProject = CrossProject("server", "client", file("."), CrossType.Full)
    .settings(
      /* Shared settings */
      libraryDependencies ++= Seq(
        "io.github.widok" %%% "widok" % "0.2.1", // !!! can't compile
        "com.lihaoyi" %%% "upickle" % "0.2.6")
    )
    .jsSettings(
      /* Scala.js settings */
    )
    .jvmSettings(
      /* JVM settings */
    )

  lazy val js = crossProject.js
  lazy val jvm = crossProject.jvm

}

The lines with %%% are not compilable, how to fix them?


Solution

  • You need to add following import

    import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._