forked from raquo/Laminar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
180 lines (157 loc) · 6.34 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import VersionHelper.{versionFmt, fallbackVersion}
// Lets me depend on Maven Central artifacts immediately without waiting
resolvers ++= Resolver.sonatypeOssRepos("public")
// Replace default sbt-dynver version with a simpler one for easier local development
// ThisBuild / version ~= (_.replaceFirst("(\\+[a-z0-9-+]*-SNAPSHOT)", "-NEXT-SNAPSHOT"))
// Makes sure to increment the version for local development
ThisBuild / version := dynverGitDescribeOutput.value
.mkVersion(out => versionFmt(out, dynverSonatypeSnapshots.value), fallbackVersion(dynverCurrentDate.value))
ThisBuild / dynver := {
val d = new java.util.Date
sbtdynver.DynVer
.getGitDescribeOutput(d)
.mkVersion(out => versionFmt(out, dynverSonatypeSnapshots.value), fallbackVersion(d))
}
ThisBuild / scalaVersion := Versions.Scala_3
ThisBuild / crossScalaVersions := Seq(Versions.Scala_2_12, Versions.Scala_2_13, Versions.Scala_3)
lazy val precompile = taskKey[Unit]("runs Laminar-specific pre-compile tasks")
precompile := DomDefsGenerator.cachedGenerate()
(Compile / compile) := ((Compile / compile) dependsOn precompile).value
lazy val websiteJS = project
.in(file("websiteJS"))
.settings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % Versions.ScalaJsDom,
(publish / skip) := true,
webpackBundlingMode := BundlingMode.LibraryOnly(),
(installJsdom / version) := Versions.JsDom,
(webpack / version) := Versions.Webpack,
(startWebpackDevServer / version) := Versions.WebpackDevServer,
//webpackBundlingMode := BundlingMode.LibraryAndApplication(),
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule)
},
scalaJSLinkerConfig ~= {
_.withSourceMap(false) // Producing source maps throws warnings on material web components complaining about missing .ts files. Not sure why.
},
scalaJSUseMainModuleInitializer := true,
(Compile / npmDependencies) ++= Seq(
"@material/mwc-button" -> "0.18.0",
"@material/mwc-linear-progress" -> "0.18.0",
"@material/mwc-slider" -> "0.18.0"
),
scalacOptions ~= { options: Seq[String] =>
options.filterNot { o =>
o.startsWith("-Wvalue-discard") || o.startsWith("-Ywarn-value-discard") || o.startsWith("-Ywarn-unused") || o.startsWith("-Wunused")
}
},
)
.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin)
.dependsOn(laminar)
lazy val website = project
.enablePlugins(MdocPlugin, DocusaurusPlugin)
.settings(
mdocIn := file("website/docs"),
mdocJS := Some(websiteJS),
mdocJSLibraries := (websiteJS / Compile / fullOptJS / webpack).value,
(publish / skip) := true,
mdocVariables := Map(
"js-mount-node" -> "containerNode",
"js-batch-mode" -> "true"
// // Use these as @VERSION@ in mdoc-processed .md files
// "LAMINAR_VERSION" -> version.value.replace("-SNAPSHOT", ""), // This can return incorrect version too easily
// "SCALA_VERSION" -> scalaVersion.value
)
)
lazy val laminar = project.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(
libraryDependencies ++= Seq(
"com.raquo" %%% "airstream" % Versions.Airstream,
// "com.raquo" %%% "domtypes" % Versions.ScalaDomTypes, #Note this is a compile-time dependency. See `project/build.sbt`
"com.raquo" %%% "ew" % Versions.Ew,
"com.raquo" %%% "domtestutils" % Versions.ScalaDomTestUtils % Test,
"org.scalatest" %%% "scalatest" % Versions.ScalaTest % Test,
),
scalacOptions ++= Seq(
"-feature",
"-language:implicitConversions,higherKinds,existentials",
),
scalacOptions ~= { options: Seq[String] =>
options.filterNot(Set(
"-Ywarn-value-discard",
"-Wvalue-discard"
))
},
scalacOptions ++= sys.env.get("CI").map { _ =>
val localSourcesPath = (LocalRootProject / baseDirectory).value.toURI
val remoteSourcesPath = s"https://raw.githubusercontent.com/raquo/Laminar/${git.gitHeadCommit.value.get}/"
val sourcesOptionName = if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
s"${sourcesOptionName}:$localSourcesPath->$remoteSourcesPath"
},
// @TODO[Build,Scala 2.12] This should only be disabled for tests, but I can't figure out how to make @unused work in 2.12
// We do have the stub defined in Airstream, but it throws deprecation errors in Laminar for some reason as if
// the unused value is in fact used, but that doesn't seem right.
//(Test / scalacOptions) ~= { options: Seq[String] =>
scalacOptions ~= { options: Seq[String] =>
options.filterNot { o =>
o.startsWith("-Ywarn-unused") || o.startsWith("-Wunused")
}
},
(Compile / doc / scalacOptions) ~= (_.filterNot(
Set(
"-deprecation",
"-explain-types",
"-explain",
"-feature",
"-language:existentials,experimental.macros,higherKinds,implicitConversions",
"-unchecked",
"-Xfatal-warnings",
"-Ykind-projector",
"-from-tasty",
"-encoding",
"utf8",
)
)),
(Compile / doc / scalacOptions) ++= Seq(
"-no-link-warnings" // Suppress scaladoc "Could not find any member to link for" warnings
),
(Test / parallelExecution) := true,
jsEnv := new jsenv.playwright.PWEnv(
browserName = "chromium",
headless = true,
showLogs = false
),
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
},
scalaJSUseMainModuleInitializer := true,
(Compile / fastOptJS / scalaJSLinkerConfig) ~= {
_.withSourceMap(false)
}
)
.settings(
name := "Laminar",
normalizedName := "laminar",
organization := "com.raquo",
homepage := Some(url("https://laminar.dev")),
licenses += ("MIT", url("https://github.com/raquo/Laminar/blob/master/LICENSE.md")),
scmInfo := Some(
ScmInfo(
url("https://github.com/raquo/Laminar"),
"scm:git@github.com/raquo/Laminar.git"
)
),
developers := List(
Developer(
id = "raquo",
name = "Nikita Gazarov",
email = "nikita@raquo.com",
url = url("https://github.com/raquo")
)
),
(Test / publishArtifact) := false,
Test / scalaJSStage := FullOptStage,
pomIncludeRepository := { _ => false },
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)