-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
107 lines (93 loc) · 3.84 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
import com.typesafe.sbt.packager.SettingsHelper._
val Versions = new {
val scala = "2.13.7"
val scalaJSReact = "2.0.1"
val scalaCss = "1.0.0"
val webextensionPolyfill = "0.8.0"
val webextensionPolyfillTypes = "0.8.2"
val reactJS = "17.0.2"
val reactJSTypes = "17.0.38"
val reactJSDOMTypes = "17.0.11"
}
ThisBuild / organization := "io.github.er1c"
ThisBuild / homepage := Some(url("https://github.com/er1c/scala-js-browser-extension-example"))
ThisBuild / licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / description := "Example browser extension written in Scala."
ThisBuild / developers := List(
Developer("ericpeters", "Eric Peters", "[email protected]", url("https://github.com/er1c"))
)
ThisBuild / scmInfo := Some(ScmInfo(url(s"https://github.com/er1c/scala-js-browser-extension-example"), s"[email protected]:er1c/scala-js-browser-extension-example.git"))
ThisBuild / scalaVersion := Versions.scala
// Manually update ci config via `sbt githubWorkflowGenerate`
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest")
ThisBuild / githubWorkflowEnv := Map.empty
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
commands = List("universal:packageBin", "checkArchive"),
env = Map.empty
)
)
ThisBuild / githubWorkflowPublishTargetBranches := Nil
ThisBuild / scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-encoding",
"UTF-8",
"-Xfatal-warnings",
"-language:_",
// Warn when dead code is identified.
"-Ywarn-dead-code",
// Warn when numerics are widened.
"-Ywarn-numeric-widen",
"-language:postfixOps",
)
lazy val plugin = project
.in(file("plugin"))
.enablePlugins(ScalaJSPlugin)
.enablePlugins(ScalablyTypedConverterPlugin)
.enablePlugins(ScalaJSBundlerPlugin)
.enablePlugins(UniversalPlugin)
.settings(
/* disabled because it somehow triggers many warnings */
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withSourceMap(false),
Compile / fastOptJS / webpackDevServerExtraArgs += "--mode=development",
Compile / fullOptJS / webpackDevServerExtraArgs += "--mode=production",
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % Versions.scalaJSReact,
"com.github.japgolly.scalajs-react" %%% "extra" % Versions.scalaJSReact,
"com.github.japgolly.scalacss" %%% "core" % Versions.scalaCss,
"com.github.japgolly.scalacss" %%% "ext-react" % Versions.scalaCss
),
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"webextension-polyfill" -> Versions.webextensionPolyfill,
"@types/webextension-polyfill" -> Versions.webextensionPolyfillTypes,
"react" -> Versions.reactJS,
"@types/react" -> Versions.reactJSTypes,
"react-dom" -> Versions.reactJS,
"@types/react-dom" -> Versions.reactJSDOMTypes,
),
scalaJSUseMainModuleInitializer := true,
// Map all assets produced by the ScalaJs Bundler to their location within the archive
Universal / mappings ++= (Compile / fullOptJS / webpack).value.map { f =>
f.data -> s"assets/${f.data.getName()}"
},
topLevelDirectory := None,
makeDeploymentSettings(Universal, Universal / packageBin, "zip"),
useYarn := true,
TaskKey[Unit]("checkArchive") := {
val expected : List[String] = List(
"icon.png",
"index.html",
"manifest.json",
"images/graphic.png",
"assets/plugin-opt-bundle.js",
)
val archive = (Universal / packageBin).value
assert(archive.exists() && archive.isFile())
val entries = new ZipHelper(archive).entries
assert(expected.size == entries.size, s"expected.size: ${expected.size} != entries.size: ${entries.size}")
assert(expected.forall(e => entries.contains(e)), s"expected: ${expected} != entries: ${entries}")
},
)