Skip to content

Commit

Permalink
feat: update to modern leptos+nix techniques
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Jul 20, 2024
1 parent 0597985 commit e018547
Show file tree
Hide file tree
Showing 22 changed files with 381 additions and 424 deletions.
502 changes: 180 additions & 322 deletions Cargo.lock

Large diffs are not rendered by default.

27 changes: 12 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["app", "frontend", "server"]
members = ["crates/*"]

# need to be applied only to wasm build
[profile.wasm-release]
Expand Down Expand Up @@ -30,45 +30,42 @@ tower-http = { version = "0.5", features = ["full"] }
wasm-bindgen = "=0.2.92"
pulldown-cmark = "0.9"

[patch.crates-io]
leptos = { git = 'https://github.com/leptos-rs/leptos.git', rev = "c06f6be" }
leptos_axum = { git = 'https://github.com/leptos-rs/leptos.git', rev = "c06f6be" }
leptos_meta = { git = 'https://github.com/leptos-rs/leptos.git', rev = "c06f6be" }
leptos_router = { git = 'https://github.com/leptos-rs/leptos.git', rev = "c06f6be" }

# See https://github.com/akesson/cargo-leptos for documentation of all the parameters.

# A leptos project defines which workspace members
# that are used together frontend (lib) & server (bin)
[[workspace.metadata.leptos]]
# this name is used for the wasm, js and css file names
name = "blog"
name = "site"

hash-files = true
# we turn this on for the release but keep it off in dev
# https://github.com/leptos-rs/cargo-leptos/issues/271
hash-files = false

bin-package = "server"
lib-package = "frontend"
bin-package = "site-server"
lib-package = "site-frontend"

site-root = "target/site"
site-pkg-dir = "pkg"

style-file = "style/main.scss"
assets-dir = "public"
style-file = "crates/site-app/style/main.scss"
assets-dir = "crates/site-app/public"

site-addr = "127.0.0.1:3000"
reload-port = 3001

browserquery = "defaults"

tailwind-input-file = "style/main.scss"
tailwind-input-file = "crates/site-app/style/main.scss"
tailwind-config-file = "crates/site-app/style/tailwind/tailwind.config.js"

# set by cargo-leptos
watch = false
watch-additional-files = [ "content/*" ]
env = "DEV"

bin-features = []
bin-default-features = false

lib-features = []
lib-default-features = false
lib-profile-release = "wasm-release"
2 changes: 1 addition & 1 deletion app/Cargo.toml → crates/site-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "app"
name = "site-app"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/src/lib.rs → crates/site-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub fn App() -> impl IntoView {

view! {
<div class="bg-neutral-800 min-h-screen">
<Stylesheet href="/pkg/blog.css"/>
<Style>{include_str!("../../style/iosevka_term.css")}</Style>
<Stylesheet href="/pkg/site.css"/>
<Style>{include_str!("../style/iosevka_term.css")}</Style>

// preloads the fonts
<leptos_meta::Link
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions frontend/Cargo.toml → crates/site-frontend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "frontend"
name = "site-frontend"
version = "0.1.0"
edition = "2021"

Expand All @@ -9,7 +9,7 @@ crate-type = ["cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
app = { path = "../app", default-features = false, features = ["hydrate"] }
site-app = { path = "../site-app", default-features = false, features = ["hydrate"] }
leptos = { workspace = true, features = [ "hydrate" ] }

console_error_panic_hook.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib.rs → crates/site-frontend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This has to be imported for `wasm_bindgen` to work.
#[allow(unused_imports)]
use app::*;
use leptos::*;
#[allow(unused_imports)]
use site_app::*;
use wasm_bindgen::prelude::wasm_bindgen;

#[wasm_bindgen]
Expand Down
4 changes: 2 additions & 2 deletions server/Cargo.toml → crates/site-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "server"
name = "site-server"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
app = { path = "../app", default-features = false, features = ["ssr"] }
site-app = { path = "../site-app", default-features = false, features = ["ssr"] }
leptos = { workspace = true, features = [ "ssr" ]}
leptos_axum.workspace = true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use app::App;
use axum::{
body::Body,
extract::State,
http::{Request, Response, StatusCode, Uri},
response::{IntoResponse, Response as AxumResponse},
};
use leptos::*;
use site_app::App;
use tower::ServiceExt;
use tower_http::services::ServeDir;

Expand Down
2 changes: 1 addition & 1 deletion server/src/main.rs → crates/site-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use app::*;
use axum::{routing::post, Router};
use fileserv::file_and_error_handler;
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use site_app::*;
use tower_http::compression::CompressionLayer;

pub mod fileserv;
Expand Down
Loading

0 comments on commit e018547

Please sign in to comment.