通过Scala.js'sbt fastOptJS
,我只想将myproject/target/scala-2.11/web-fastopt.js
重定向到myproject/js
是否可能?
web-jsdeps.js
相同 - 将其重定向到/myproject/libs
我读过这个 Scala.js compilation destination
这似乎太复杂了。我只有一个项目,而不是两个或三个,没有播放框架,只是普通的文件到文件夹副本。 更新
我的设置project/BuildProject.scala
:
lazy val chromePluginProject = Project(id = "chromePlugin", base = file(".")).enablePlugins(ScalaJSPlugin).
settings(
version := "0.1",
scalaVersion := Versions.scala,
artifactPath in(Compile, fastOptJS) := baseDirectory.value / "plugin" / "src" / "content" / "fastOpt.js",
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }, // TODO:
//mainClass := Some("branch.ScalaJsSample"),
libraryDependencies ++= scalaJsDependencies,
libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0",
libraryDependencies += "com.lihaoyi" %%% "upickle" % Versions.upickle,
libraryDependencies += "com.lihaoyi" %%% "scalatags" % Versions.scalaTags,
// we will not use use DOM directly so commenting it
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % Versions.dom,
jsDependencies += "org.webjars" % "jquery" % Versions.jquery / "jquery.js",
jsDependencies += "org.webjars.bower" % "webcomponents.js" % Versions.webcomponents / "webcomponents-lite.js",
// After reloading and rerunning fastOptJS,
// this will create scala-js-jsdeps.js
skip in packageJSDependencies := false,
// allows DOM be available from from console' run (so no "ReferenceError: "window" is not defined." error would appear)
jsDependencies += RuntimeDOM, // it will use PhantomJS, basically
scalaJSUseRhino in Global := false //will use node.js to run the thing
)
我的文件结构是:
<root>/plugin/src/content
我要复制fastOpt.js
正如我所说,它在/target/scala-2.11 /
中的* -site-jsdeps.js中创建答案 0 :(得分:4)
是的,你可以这样做:
artifactPath in(Compile, packageScalaJSLauncher) := baseDirectory.value / ".." / "jvm" / "webapp" / "js" / "launcher.js",
artifactPath in(Compile, fastOptJS) := baseDirectory.value / ".." / "jvm" / "webapp" / "js" / "fastOpt.js",
artifactPath in(Compile, fullOptJS) := baseDirectory.value / ".." / "jvm" / "webapp" / "js" / "fullOpt.js",
artifactPath in(Compile, packageJSDependencies) := baseDirectory.value / ".." / "jvm" / "webapp" / "js" / "dependency.js"
更多信息,请参阅https://github.com/yuanqingfei/gdbscan-akka-d3js/blob/master/build.sbt
答案 1 :(得分:1)
只需使用此sbt设置:
crossTarget in fastOptJS := baseDirectory.value / "js"
答案 2 :(得分:1)
在BuildProject.scala
(object BuildProject extends Build {
)或build.sbt
添加此行:
lazy val copyJsTask = TaskKey[Unit]("copyJsTask", "Copy javascript files to target directory")
lazy val myPluginProject = Project(id = "my-plugin", base = file(".")).
settings(
copyJsTask := {
val outDir = baseDirectory.value / "plugin/src/content"
val inDir = baseDirectory.value / "target/scala-2.11"
val files = Seq("my-plugin-fastopt.js", "my-plugin-fastopt.js.map") map { p => (inDir / p, outDir / p) }
IO.copy(files, overwrite = true)
}, ..
在项目的根目录中添加新文件 .sbtrc
内容:
alias jsCompile=;fastOptJS;copyJsTask
-
令人满意的是它的“复杂性”,npm / grunt / linux批次等。