Skip to content

hackus/Scala3ZioFullStack

Repository files navigation

Create scala fullstack project using Scala3, ScalaJs, ZIO

Building the project from scratch


Server

1. sbt new scala/scala3.g8
2. mkdir server
3. mv src server/

Client

npm create [email protected]
1. -> client
2. -> vanilla
3. -> javascript

Deploy locally

cd client
npm install
npm run dev

Install scala-js plugin

cd client
npm install -D @scala-js/[email protected]

Install scalably-typed plugin

I Used ScalaJs-ScalablyTyped, I am not 100% sure they are both needed however I blindly installed these plugins, will check later if any of them can be omitted

npm install -S [email protected]
npm install -D @types/[email protected] [email protected]

Implementation


build.sbt

Have used Medium-ScalaFullstackWebApp example and partially RockTheJvm-ZioFullstackWebApp

Create common dir to keep shared code between server and client 
    uphold by -common- in build.sbt    
Configure multimodule project in build.sbt
    uphold by -root- in build.sbt    
Configure server
    uphold by -server- in build.sbt
Configure client
    uphold by -client- in build.sbt

One thing I noticed the way RockTheJvm-ZioFullstackWebApp is configuring the common is most suitable to the way I want it to be the result is clean and easy to understand, try the example from Medium-ScalaFullstackWebApp to observe the difference.

A very good thing I learned from IdiomaticSoft was the aggregate function in multi-module projects.


plugins.sbt

Add the required plugins.

Run


  • Important

    Start from the client because, when server is started first, client does not start.
    
  • Before running Client first time

    cd client
    npm install
    
  • Run Client

    cd client  
    npm run dev
    
  • Run Server
    To publish use sbt publishlocal but it is not required

    sbt server/run
    
  • Refresh Client


References:

About

Create full stack scala project using Javascript, Scala, ScalaJs, Zio

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •