-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
56 lines (42 loc) · 1.5 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
51
52
53
54
55
56
import java.io.PrintWriter
import java.nio.file.{Files, StandardCopyOption}
import scala.collection.JavaConverters._
enablePlugins(ScalaJSPlugin)
name := "tkachuko-blog"
scalaVersion := "2.12.2"
scalaBinaryVersion := "2.12"
sbtVersion := "1.1.6"
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.2",
"com.lihaoyi" %%% "scalatags" % "0.6.7",
"com.typesafe.play" %%% "play-json" % "2.6.6",
"com.lihaoyi" %%% "utest" % "0.6.0" % Test,
"org.scalatest" %%% "scalatest" % "3.0.4" % Test
)
testFrameworks += new TestFramework("utest.runner.Framework")
scalaJSStage := FastOptStage
mainClass := Some("com.tkachuko.blog.frontend.App")
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) Copy everything from resources
new File("./src/main/resources/")
.listFiles()
.foreach(file =>
Files.copy(file.toPath, new File(".", file.getName).toPath, StandardCopyOption.REPLACE_EXISTING)
)
// 3) Replace links in index.html
val index = new File(".", "index.html")
val content =
Files.readAllLines(index.toPath).asScala
.toList
.mkString("\n")
.replaceAll("fastopt", "opt")
.replaceAll("target/scala-2.12/", "")
val writer = new PrintWriter(index)
writer.write(content)
writer.close()
}