-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
50 lines (37 loc) · 1.35 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.PrintWriter
import java.nio.file.{Files, StandardCopyOption}
import scala.io.Source
enablePlugins(ScalaJSPlugin)
name := "akka-js-snake"
scalaVersion := "2.11.8"
scalaBinaryVersion := "2.11"
sbtVersion := "0.13.13"
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.8.0",
"com.lihaoyi" %%% "scalatags" % "0.4.5",
"org.akka-js" %%% "akkajsactor" % "1.2.5.1",
"com.softwaremill.quicklens" %%% "quicklens" % "1.4.8",
"org.akka-js" %%% "akkajstestkit" % "1.2.5.1" % Test,
"org.scalatest" %% "scalatest" % "3.0.1" % Test,
"org.scalatest" %%% "scalatest" % "3.0.1" % Test
)
scalaJSUseMainModuleInitializer := true
scalaJSStage := FastOptStage
val githubPages = taskKey[Unit]("Copy index.html and js files to match github pages layout")
githubPages := {
// 1) Copy compiled prod js
val js = (fullOptJS in Compile).value.data
val jsTarget = new File(".", js.getName)
Files.copy(js.toPath, jsTarget.toPath, StandardCopyOption.REPLACE_EXISTING)
// 2) Read current index.html
val indexContent = Source.fromFile("./src/main/resources/index.html")
.mkString
.replace("fastopt", "opt")
.replace("target/scala-2.11/", "")
// 3) Create prod index.html
val index = new File(".", "index.html")
if (index.exists()) index.delete()
val writer = new PrintWriter(index)
writer.write(indexContent)
writer.close()
}