2016-05-10 48 views
2

通過Scala.js'sbt fastOptJS,我只是想將myproject/target/scala-2.11/web-fastopt.js重定向到myproject/js是可能的嗎?ScalaJS簡單地將複雜度輸出重定向到指定的目錄

同爲web-jsdeps.js - 將其重定向到/myproject/libs

我讀過這個 Scala.js compilation destination

,這似乎太複雜了。我只有一個項目,而不是兩個或三個,沒有播放框架,只是簡單的文件到文件夾副本。

UPDATE: 我的設置,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

正如我所說的它會在*上門,jsdeps .js in /target/scala-2.11/

回答

1

只需使用此設置即可:

crossTarget in fastOptJS := baseDirectory.value/"js" 
+0

似乎現在對我有用,我試圖把它放在.settings(..)或項目之外。我也試過這個:http://stackoverflow.com/questions/27505957/using-scala-js-to-compile-only-and-not-override-run-in-sbt eventhough再次有兩個項目。 – ses

+0

'crossTarget in(Compile,fastOptJS)'然後呢? – sjrd

+0

nope。更新了我的問題。 – ses

3

是的,你可以這樣說:

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

+0

我想所有的工作,如果我使用'crossProject',在我的情況下,我只使用一個項目,js一:'lazy val myChromePluginProject = Project(id =「my-project」,base = file(「。」))。 enablePlugins(ScalaJSPlugin)。 設置(artifactPath in(Compile,fastOptJS):= baseDirectory.value /「plugin」/「src」/「content」/「fastOpt.js」,「...它不復制 更新了我的問題。 – ses

0

BuildProject.scalaobject BuildProject extends Build {)或build.sbt添加此line:

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批處理。