Starter template for Svelte frontend apps with Rust Rocket backend server.
We will use Rust nightly.
Create a new project based on this example: Mozilla Developer Network, Getting Started with Svelte
Optional: Assuming you are not using this repository, to start with a clean slate for Rust/Svelte
npx degit sveltejs/template moz-todo-svelte
cd moz-todo-svelte
cargo new myproject
#now move stuff around
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
echo "Install rust and cargo (Rust's package manager)"
curl https://sh.rustup.rs -sSf | sh
echo "clone, or better yet your github cli tool"
git clone https://github.com/joemooney/rust-rocket-svelte
or
gh repo clone joemooney/rust-rocket-svelte
rustup override set nightly
npm install
These are the steps to get to the initial point for starting development.
Then we move the svelte related files into the client
directory etc.
Start Rocket server and Rollup in two different terminals
To build and hot reload svelte components, this will not launch a http server.
npm run dev
Compile and run the rust rocket http server:
cargo run
client
directory.** Upon saving changes live-reloading via rollup will be rendered in the browser.
src
directory.** To rebuild Rust code use cargo run after saving your changes.
public
direcotry. Including the JS code compiled by Svelte Compiler.To create an optimised version of the app:
npm run build
cargo build
Initial barebones Rust/Rocket/Svelte page working.
Got communication working from Svelete client calling Rust asynchronously.
Added Material UI components to create a first draft user interface.
TODO: I did not keep track of all that I did, need to repeat the process.
npm i svelte-material-ui
npm i -D @smui/data-table
npm i -D @smui/tab
npm i -D @smui/tab-bar
npm i svelte-material-icons