/
build.sbt
84 lines (79 loc) · 3.2 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
import org.scalajs.linker.interface.ModuleKind.CommonJSModule
lazy val tutorial =
crossProject(JSPlatform, JVMPlatform)
.in(file("."))
.settings(
organization := "com.olvind",
scalaVersion := "2.13.5",
scalacOptions ++= Seq("-encoding", "UTF-8", "-feature", "-unchecked", "-Xlint", "-deprecation"),
testFrameworks += new TestFramework("utest.runner.Framework"),
/* shared dependencies */
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "upickle" % "1.3.11",
"com.lihaoyi" %%% "autowire" % "0.3.3",
"com.lihaoyi" %%% "utest" % "0.7.8" % Test
)
)
lazy val tutorialJvm: Project =
tutorial.jvm
.enablePlugins(WebScalaJSBundlerPlugin)
.settings(
name := "tutorialJVM",
/* Normal scala dependencies */
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % "10.2.4",
"com.typesafe.akka" %% "akka-stream" % "2.6.14",
),
scalaJSProjects := Seq(tutorialJs),
Assets / pipelineStages := Seq(scalaJSPipeline)
)
lazy val tutorialJs: Project =
tutorial.js
.enablePlugins(ScalablyTypedConverterPlugin)
.settings(
name := "tutorialJS",
webpackDevServerPort := 8081,
/* discover main and make the bundle run it */
scalaJSUseMainModuleInitializer := true,
useYarn := true,
/* disabled because it somehow triggers many warnings */
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withSourceMap(false).withModuleKind(CommonJSModule),
/* javascript dependencies */
Compile / npmDependencies ++= Seq(
"antd" -> "4.15.0",
"react" -> "17.0.2",
"react-dom" -> "17.0.2",
"@types/react" -> "17.0.3",
"@types/react-dom" -> "17.0.3",
),
/* custom webpack file */
Compile / webpackConfigFile := Some((ThisBuild / baseDirectory).value / "custom.webpack.config.js"),
Compile / fastOptJS / webpackDevServerExtraArgs += "--mode=development",
/* dependencies for custom webpack file */
Compile / npmDevDependencies ++= Seq(
"webpack-merge" -> "5.2.0",
"css-loader" -> "5.0.0",
"style-loader" -> "2.0.0",
"file-loader" -> "6.1.1",
"url-loader" -> "4.1.1",
"html-webpack-plugin" -> "4.5.0",
),
/* don't need to override anything for test. revisit this if you depend on code which imports resources,
for instance (you probably shouldn't need to) */
Test / webpackConfigFile := None,
Test / npmDependencies ++= Seq(
"source-map-support" -> "0.5.19"
),
Test / requireJsDomEnv := true,
stIgnore ++= List("source-map-support", "@babel/runtime"),
stFlavour := Flavour.Slinky,
stReactEnableTreeShaking := Selection.All,
scalacOptions += "-Ymacro-annotations",
)
def cmd(name: String, commands: String*) =
Command.command(name)(s => s.copy(remainingCommands = commands.toList.map(cmd => Exec(cmd, None)) ++ s.remainingCommands))
commands ++= List(
cmd("dev", "fastOptJS::startWebpackDevServer", "~;tutorialJVM/reStart;tutorialJS/fastOptJS::webpack"),
cmd("devFront", "fastOptJS::startWebpackDevServer", "~tutorialJS/fastOptJS::webpack"),
cmd("devBack", "~;tutorialJVM/reStart"),
)