addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.4") addSbtPlugin(“org.scala-js” % “sbt-scalajs” % “1.7.0”) addSbtPlugin(“org.scala-js” % “sbt-jsdependency” % “1.0.2”) addSbtPlugin(“ch.epfl.scala”%“sbt-scalajs-bundler”%“0.20.0”) addSbtPlugin(“com.eed3si9n”%“sbt-buildinfo”%“0.10.0”) addSbtPlugin(“org.scala-native” % “sbt-scala-native” % “0.3.7”) addSbtPlugin(“org.portable-scala” % “sbt-scalajs-crossproject” % “1.2.0”) addSbtPlugin(“org.portable-scala” % “sbt-scala-native-crossproject” % “1.2.0”)<p>在文章的<strong>第2步</strong>中,它表示只需将以下内容添加到'build.sbt'文件中:</p>
val scalaGraalVer = "1.0.1"; 惰性 val webappSsr = crossProject(“webapp-ssr”) 惰性 val webappSsrJs = webappSsr.js .dependsOn(myScalaJsWebapp) // 将此处更改为您真正的SJS模块名称 。设置( 库依赖项 += Seq( “com.github.japgolly.scala-graal” %%%“核心js” % scalaGraalVer, “com.github.japgolly.scala-graal” %%%“ext-boopickle” % scalaGraalVer ), scalaJSLinkerConfig ~= { _.withSourceMap(false) }, artifactPath in (Compile, fastOptJS) := (crossTarget.value / "webapp-ssr.js"), artifactPath in (Compile, fullOptJS) := (crossTarget.value / "webapp-ssr.js") ) lazy val webappSsrJvm = webappSsr.jvm .settings( libraryDependencies ++= Seq( "com.github.japgolly.scala-graal" %% "core" % scalaGraalVer, "com.github.japgolly.scala-graal" %% "core-js" % scalaGraalVer, "com.github.japgolly.scala-graal" %% "ext-boopickle" % scalaGraalVer ), unmanagedResources in Compile += Def.taskDyn { val stage = (scalaJSStage in Compile in webappSsrJs).value val task = stageKey(stage) Def.task((task in Compile in webappSsrJs).value.data) }.value) )</pre> <p>所以我目前在这里有2个问题:</p> <ol> <li><p><code>crossProject</code>似乎不接受<code>String</code>作为参数,即:</p> <p><code>def crossProject(平台:sbtcrossproject.Platform*)</code></p> </li> <li><p>在<code>val task = stageKey(stage)</code>处 - <code>stageKey</code>不是一个被识别的函数。我在网上搜索过,但无法弄清楚它的位置,因此不知道我缺少什么或是否有其他方法。</p> </li> </ol></p>
P粉3788901062023-08-31 10:11:47
就像@tdimoff已经说过的那样,sbtcrossproject库的crossProject
方法不接受字符串参数,所以这行代码lazy val webappSsr = crossProject("webapp-ssr")
应该替换为lazy val webappSsr = crossProject(JSPlatform, JVMPlatform)
。
关于stageKey
函数,它似乎是scalajs-bundler库的一部分,所以您需要添加以下库依赖:
libraryDependencies += "ch.epfl.scala" % "scalajs-bundler" % "0.20.0"
这样应该可以使用stageKey
函数。