Skip to content

Commit

Permalink
Add Workbench plugin to run example self contained
Browse files Browse the repository at this point in the history
Previously the url was hardcoded to a windows path where I assume a
local web server was serving the example.

This plugin loads the example from `sbt` with the command
`startWorkbenchServer`, along with some helpful debugging features.
  • Loading branch information
dropofwill committed Oct 27, 2019
1 parent 3b24c1b commit abf482d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
9 changes: 7 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
scalaVersion := "2.12.9",
)

// Run the example project by running `sbt startWorkbenchServer` and navigating to
// http://localhost:8888/index-dev.html
lazy val example = project
.in(file("example-scalajs-app"))
.settings(common)
Expand All @@ -83,7 +85,10 @@ lazy val example = project
"com.lihaoyi" %%% "scalatags" % "0.7.0"
),
test in Test := {},
artifactPath in (Compile, fastOptJS) := file("C:\\Users\\Stephen Carman\\software\\nginx-1.15.9\\html\\app-example.js")
// Workbench config
localUrl := ("localhost", 8080),
workbenchDefaultRootObject := Some(("example-scalajs-app/", "example-scalajs-app/")),
workbenchStartMode := WorkbenchStartModes.Manual
)
.enablePlugins(ScalaJSPlugin)
.enablePlugins(ScalaJSPlugin, WorkbenchPlugin)
.dependsOn(core.js)
4 changes: 3 additions & 1 deletion example-scalajs-app/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
<title>Spotify</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script type="text/javascript" src="app-example.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body id="body">
<script type="text/javascript"
src="./target/scala-2.12/example-app-fastopt.js"></script>
<script type="text/javascript" src="/workbench.js"></script>
</body>
</html>
17 changes: 9 additions & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.3.0"

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.4")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.4")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.1")

0 comments on commit abf482d

Please sign in to comment.