Skip to content

Commit 69208bc

Browse files
committed
Restore global dep demo
1 parent e379401 commit 69208bc

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

example/build.sbt

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,56 @@ val commonSettings = Seq(
2828
)
2929

3030
val generatedGlobalDir = file("generated/global")
31+
val compileStatics = taskKey[Unit]("Compiles all static files.")
3132
val copyAssets = taskKey[Unit]("Copies all assets to the target directory.")
32-
val root = project.in(file("."))
33+
34+
lazy val root: Project = project.in(file("."))
35+
.aggregate(`jquery-bundler-demo`, `jquery-global-demo`)
36+
.settings(
37+
crossScalaVersions := Nil,
38+
)
39+
40+
lazy val `jquery-global-demo` = project.in(file("global-demo"))
3341
.enablePlugins(ScalaJSPlugin)
34-
.settings(commonSettings)
42+
.settings(
43+
commonSettings,
3544

36-
val generatedBundlerDir = file("generated")
37-
val compileStatics = taskKey[Unit]("Compiles all static files.")
45+
jsDependencies ++= Dependencies.jsDeps.value,
46+
47+
sourceDirsSettings(_.getParentFile),
48+
49+
/* move these files out of target/. */
50+
Compile / fullOptJS / crossTarget := generatedGlobalDir,
51+
Compile / fastOptJS / crossTarget := generatedGlobalDir,
52+
Compile / packageJSDependencies / crossTarget := generatedGlobalDir,
53+
Compile / packageMinifiedJSDependencies / crossTarget := generatedGlobalDir,
54+
55+
Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value,
56+
Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value,
57+
58+
scalaJSUseMainModuleInitializer := true,
59+
60+
copyAssets := {
61+
IO.copyFile(
62+
root.base / "src/main/assets/index.html",
63+
generatedGlobalDir / "index.html"
64+
)
65+
},
66+
67+
compileStatics := (Compile / fastOptJS).value,
68+
69+
Compile / fastOptJS / artifactPath :=
70+
(Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
71+
Compile / fullOptJS / artifactPath :=
72+
(Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
73+
Compile / packageJSDependencies / artifactPath :=
74+
(Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js",
75+
Compile / packageMinifiedJSDependencies / artifactPath :=
76+
(Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js"
77+
)
3878

39-
val example = project.in(file("."))
79+
val generatedBundlerDir = file("generated/bundler")
80+
lazy val `jquery-bundler-demo` = project.in(file("bundler-demo"))
4081
.enablePlugins(ScalaJSBundlerPlugin)
4182
.settings(
4283
commonSettings,
@@ -47,7 +88,7 @@ val example = project.in(file("."))
4788

4889
copyAssets := {
4990
IO.copyFile(
50-
sourceDirectory.value / "main/assets/index.html",
91+
root.base / "src/main/assets/index.html",
5192
generatedBundlerDir / "index.html"
5293
)
5394
},

example/project/Dependencies.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
12
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
23
import sbt._
34

45
object Dependencies {
56
val udashCoreVersion = "0.8.3"
6-
val udashJQueryVersion = "3.0.0-SNAPSHOT"
7+
val udashJQueryVersion = "3.0.2"
78

89
val deps = Def.setting(Seq[ModuleID](
910
"io.udash" %%% "udash-core" % udashCoreVersion,
1011
"io.udash" %%% "udash-jquery" % udashJQueryVersion
1112
))
13+
14+
val jsDeps = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID](
15+
"org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js"
16+
))
1217
}

0 commit comments

Comments
 (0)