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
4.0 KiB

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