Closed LennDG closed 6 years ago
JsDom is provided for js use, so you should use %%%
instead of %%
. This way, you will get the JsDom object available.
Oh I see, I did not notice that. Thanks!
I must be doing something wrong. I am new to sbt and I can't seem to get the scalatags jar into my lib using this method.
scalacOptions in ThisBuild ++= Seq(
"-encoding",
"UTF-8",
"-feature",
"-deprecation",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-language:higherKinds"
)
lazy val proman = crossProject
.in(file("."))
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %% "scalatags" % "0.6.7"
) ++ Seq("circe-core", "circe-generic", "circe-parser").map(
"io.circe" %%% _ % "0.8.0"
)
)
.jvmSettings(
name := "jvm",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "scalatags" % "0.6.7",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"com.typesafe.slick" %% "slick" % "3.2.1",
"com.h2database" % "h2" % "1.3.148" % "test"
) ++ Seq("http4s-blaze-server", "http4s-dsl", "http4s-circe").map(
"org.http4s" %% _ % "0.17.5"
)
)
.jsSettings(
name := "js",
scalaJSUseMainModuleInitializer := true
)
// Needed, so sbt finds the projects
lazy val server = proman.jvm
.settings(
scalaJSProjects := Seq(client),
pipelineStages in Assets := Seq(scalaJSPipeline),
managedClasspath in Runtime += (packageBin in Assets).value
).enablePlugins(SbtWeb)
lazy val client = proman.js.enablePlugins(ScalaJSPlugin, ScalaJSWeb)
is my build.sbt file. What command do I run to get the libraries correctly downloaded?
Do you really use a server part ? Do you do some http requests ? If not, a JS project is enough.
Practice project that has a server and a JS program for the client. I just realized that JsDom can only be used in the JS part.
Yes. But you can use Text (https://github.com/lihaoyi/scalatags/blob/master/scalatags/shared/src/main/scala/scalatags/Text.scala) from the jvm side.
I have indeed been using Text to generate HTML, I thought to use JsDom to immediately generate event handlers and stuff instead of having to do that client side, but that might just not be possible. First time I'm doing anything web development related.
You can have a look to my facade lib scaladget and to demo to have an idea how to use these objects (https://github.com/openmole/scaladget).
Thanks, I will!
As explained in the documentation I used
libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.6.7"
to include scalatags in my project.However, when I try to import scalatags.JsDom._ I get the error
object JsDom is not a member of package scalatags
Upon further inspection by unzipping the scalatags.jar I could not find JsDom package. Please follow up.