我正在使用Scalatags ... app使用交叉构建方法开发经典的ScalaJS:
<root folder>
- client
- project
- server
- shared
- build.sbt
运行良好sbt re-start
或sbt run-main WebServer
现在,使用 sbt-native-pagkager 插件,我想打包所有内容并为我的项目生成一个启动脚本。
启动脚本生成有效,但似乎没有包含ScalaJS fastOptJs。
有一些东西可以帮助here,但绝对不是我的情况。
BTW,我的 build.sbt 文件如下所示:
val scalaV = "2.12.2"
lazy val server = (project in file("server"))
.settings(
scalaVersion := scalaV,
scalaJSProjects := Seq(client),
pipelineStages in Assets := Seq(scalaJSPipeline),
// triggers scalaJSPipeline when using compile or continuous compilation
compile in Compile := ((compile in Compile) dependsOn scalaJSPipeline).value,
libraryDependencies ++= Seq(
...
),
WebKeys.packagePrefix in Assets := "public/",
(managedClasspath in Runtime) += (packageBin in Assets).value,
// Packaging
topLevelDirectory := None // Don't add a root folder to the archive
)
.enablePlugins(SbtWeb, JavaAppPackaging)
.dependsOn(sharedJvm)
lazy val client = (project in file("client"))
.settings(
scalaVersion := scalaV,
scalaJSUseMainModuleInitializer := true,
unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value),
libraryDependencies ++= Seq(
...
),
jsDependencies ++= Seq(
...
)
)
.enablePlugins(ScalaJSPlugin, ScalaJSWeb)
.dependsOn(sharedJs)
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared"))
.enablePlugins(BuildInfoPlugin)
.settings(
scalaVersion := scalaV,
libraryDependencies ++= Seq(
...
),
// build info
buildInfoOptions += BuildInfoOption.BuildTime,
buildInfoKeys := Seq[BuildInfoKey](
),
buildInfoPackage := "com.example.build"
)
.jsSettings(
libraryDependencies ++= Seq(
...
)
)
.jsConfigure(_ enablePlugins ScalaJSWeb)
....
有任何帮助吗?非常感谢!
答案 0 :(得分:0)
我的错!
我没有在我的html模板中引用正确的javascript文件(
使用stage
生成的client-jsdeps.min.js和client-opt.js
现在工作正常!!