You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. import xerial.sbt.Sonatype._
  2. cancelable in Global := true
  3. val versions = new {
  4. val scalatest = "3.2.2"
  5. val outwatch = "61deece8"
  6. }
  7. val commonSettings = Seq(
  8. organization := "com.clovellytech",
  9. version := Version.version,
  10. scalaVersion := Version.scalaVersion,
  11. scalacOptions ++= options.scalac,
  12. scalacOptions in (Compile, console) := options.scalacConsole,
  13. updateOptions := updateOptions.value.withLatestSnapshots(false),
  14. )
  15. lazy val publishSettings = Seq(
  16. useGpg := true,
  17. publishMavenStyle := true,
  18. publishTo := sonatypePublishTo.value,
  19. publishArtifact in Test := false,
  20. homepage := Some(url("https://github.com/clovellytech/outwatch-router")),
  21. pomIncludeRepository := Function.const(false),
  22. sonatypeProfileName := "com.clovellytech",
  23. // License of your choice
  24. licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
  25. // Where is the source code hosted
  26. sonatypeProjectHosting := Some(
  27. GitHubHosting("clovellytech", "outwatch-router", "pattersonzak@gmail.com"),
  28. ),
  29. )
  30. lazy val docs = project
  31. .in(file("./router-docs"))
  32. .settings(commonSettings)
  33. .enablePlugins(MdocPlugin)
  34. .enablePlugins(MicrositesPlugin)
  35. .settings(
  36. name := "outwatch-router-docs",
  37. description := "A router for outwatch",
  38. organizationName := "com.clovellytech",
  39. organizationHomepage := Some(url("https://github.com/clovellytech")),
  40. homepage := Some(url("https://clovellytech.github.io/outwatch-router")),
  41. micrositeUrl := "https://clovellytech.github.io/outwatch-router",
  42. micrositeBaseUrl := "/outwatch-router",
  43. micrositeName := "Outwatch Router",
  44. micrositeCompilingDocsTool := WithMdoc,
  45. micrositeGithubOwner := "clovellytech",
  46. micrositeGithubRepo := "outwatch-router",
  47. scalacOptions := options.scalacConsole,
  48. )
  49. .settings(
  50. mdocVariables := Map(
  51. "VERSION" -> version.value,
  52. ),
  53. )
  54. .dependsOn(router)
  55. lazy val copyFastOptJS = TaskKey[Unit]("copyFastOptJS", "Copy javascript files to target directory")
  56. lazy val router = project
  57. .in(file("./outwatch-router"))
  58. .settings(name := "outwatch-router")
  59. .enablePlugins(ScalaJSPlugin)
  60. .enablePlugins(ScalaJSBundlerPlugin)
  61. .settings(commonSettings)
  62. .settings(
  63. useYarn := true, // makes scalajs-bundler use yarn instead of npm
  64. requireJsDomEnv in Test := true,
  65. version in webpack := "4.16.1",
  66. version in startWebpackDevServer := "3.1.4",
  67. webpackDevServerExtraArgs := Seq("--progress", "--color"),
  68. webpackConfigFile in fastOptJS := Some(baseDirectory.value / "webpack.config.dev.js"),
  69. // https://scalacenter.github.io/scalajs-bundler/cookbook.html#performance
  70. webpackBundlingMode in fastOptJS := BundlingMode.LibraryOnly(),
  71. resolvers += "jitpack".at("https://jitpack.io"),
  72. libraryDependencies ++= Seq(
  73. "com.github.outwatch.outwatch" %%% "outwatch" % versions.outwatch,
  74. "com.github.outwatch.outwatch" %%% "outwatch-util" % versions.outwatch,
  75. "org.scalatest" %%% "scalatest" % versions.scalatest % Test,
  76. ),
  77. copyFastOptJS := {
  78. val inDir = (crossTarget in (Compile, fastOptJS)).value
  79. val outDir = (crossTarget in (Compile, fastOptJS)).value / "dev"
  80. val files = Seq(
  81. "outwatch-router-fastopt-loader.js",
  82. "outwatch-router-frontend-fastopt.js",
  83. "outwatch-router-frontend-fastopt.js.map",
  84. ).map(p => (inDir / p, outDir / p))
  85. IO.copy(files, overwrite = true, preserveLastModified = true, preserveExecutable = true)
  86. },
  87. // hot reloading configuration:
  88. // https://github.com/scalacenter/scalajs-bundler/issues/180
  89. addCommandAlias(
  90. "dev",
  91. "; compile; fastOptJS::startWebpackDevServer; devwatch; fastOptJS::stopWebpackDevServer",
  92. ),
  93. addCommandAlias("devwatch", "~; fastOptJS; copyFastOptJS"),
  94. )
  95. .settings(publishSettings)
  96. lazy val root = project
  97. .in(file("."))
  98. .settings(name := "outwatch-router-root")
  99. .settings(commonSettings)
  100. .settings(
  101. skip in publish := true,
  102. )
  103. .dependsOn(router)
  104. .aggregate(router)