- bounty将在15小时后过期**。回答此问题可获得+50声望奖励。jesus g_force Harris希望引起更多人关注此问题。
我一直试图遵循integrating server-side rendering in scalajs-react的指导,但我的堆栈必须有点不同,所以它不是那么超级直接。
我使用SBT 1.5.5
,scala 2.12.10
与以下相关插件:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.4")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "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")
在本文的步骤2中,它要求在"build. sbt"文件中实现以下内容:
val scalaGraalVer = "1.0.1"
lazy val webappSsr = crossProject("webapp-ssr")
lazy val webappSsrJs = webappSsr.js
.dependsOn(myScalaJsWebapp) // change this to your real SJS module name(s)
.settings(
libraryDependencies ++= Seq(
"com.github.japgolly.scala-graal" %%% "core-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)
)
因此,我目前有两个问题:
crossProject
看起来不以String
作为参数,即,def crossProject(platforms : sbtcrossproject.Platform*)
val task = stageKey(stage)
-stageKey
是一个无法识别的函数。我在网上搜索过,但无法弄清楚它在哪里,因此我缺少什么,或者是否有办法解决。
1条答案
按热度按时间fae0ux8s1#
正如@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
函数可用。