How to link two JS bundles to a two different html pages? #154
Replies: 2 comments 7 replies
-
I assume you're using the scalajs vite plugin. Then, the logic that resolves the "scalajs:main.js" name is here: https://github.com/scala-js/vite-plugin-scalajs/blob/main/index.ts#L75 ( So, basically, "scalajs:main.js" resolves to "<scalaJSOutputDir>/main.js", and this To change that name, you need to set something like the following in your build.sbt, for both the import org.scalajs.linker.interface.OutputPatterns
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
.withOutputPatterns(OutputPatterns.withJSFile("login.js")) // or "rest.js" for the other project
} Then you should be able to refer to your login app's file as And to be clear, you need your Full disclosure – I haven't tried this myself, I found the bits and pieces for this here and here. So, if something's wrong in what I said, please let me know. |
Beta Was this translation helpful? Give feedback.
-
It may be worth considering also, that even with two endpoints like this you may still need some server-side capability to manage the authentication validation following An example would be:
How rigorous you want to go depends on your use-case but noting that Typically I'd suggest you not create a Both of these approaches could then pass a OAuth JWT to That's quite an advanced setup though, since you would need some form of server-side capability to process the authentication token and serve the static assets. If you provide us more info about what you're trying to do we may be able to guide you in the right direction 👍 |
Beta Was this translation helpful? Give feedback.
-
I'm very new to Scala JS ecosystem, and I need to split my JS App on two separate application: one for a login page and one for the rest.
If I understood correctly Scala JS App is linked to a certain page via Vite's
index.js
and
vite.config.js
and then it's just used in a certain html page i.e.
index.html
I see the solution in having two points in
vite.config.js
but how should I configure two Scala JS Apps to have smth. like
and
accordingly?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions