actix_svelte_template Svelte Themes

Actix_svelte_template

An Actix-Web template with SvelteKit served as static files

Actix Svelte Template

Here's an actix-web template that uses SvelteKit built and served as static files.

Features

Setup

We use Vite's proxy in the dev environment and serve svelte as static files in production.

Dev Requirements

  • cargo: curl https://sh.rustup.rs -sSf | sh
  • diesel_cli: cargo install diesel_cli --no-default-features --features sqlite
  • node: https://nodejs.org/en/download/current/
  • sqlite3: apt install sqlite3 libsqlite3-dev

run initial migrations

diesel setup
diesel migration run

Debug

Script

npm run dev

All traffic to localhost:3000/api/* will be forwarded to the actix web project, and anything else to the SvelteKit frontend.

Build

You can build the project with cargo. The build.rs will automatically compile the frontend to static files in the ./client/build directory.

cargo build --release

For convenience a Dockerfile was created which handles compiling the frontend to static files and building the Actix Web server into a 20mb Alpine image.

docker build -t actix-svelte-template .
docker run -d -p 8080:8080 actix-svelte-template

Top categories

Loading Svelte Themes