From f15f42b9cc8e73c3beb825595e7574f06b658e6b Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 22:32:44 +0200 Subject: [PATCH 1/8] Change .vscode settings to more generic rust-analyzer.toml --- .vscode/settings.json | 14 -------------- cargo-generate.toml | 6 +++--- rust-analyzer.toml | 2 ++ 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 rust-analyzer.toml diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b79eed9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "rust-analyzer.rustfmt.overrideCommand": [ - "leptosfmt", - "--stdin", - "--rustfmt" - ], - "editor.formatOnSave": true, - "[rust]": { - "editor.defaultFormatter": "rust-lang.rust-analyzer", - }, - "files.associations": { - "*.rs": "rust" - }, -} \ No newline at end of file diff --git a/cargo-generate.toml b/cargo-generate.toml index 9fdeb7f..b3dc547 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -7,10 +7,10 @@ default_channel = { prompt = "Use stable or nightly channel?", choices = [ "stable", "nightly", ], default = "stable", type = "string" } -vscode_settings = { prompt = "Generate default VS Code settings?", default = false, type = "bool" } +rust_analyzer_settings = { prompt = "Override `rustfmt` with `leptosfmt`?", default = false, type = "bool" } -[conditional.'vscode_settings == false'] -ignore = [".vscode"] +[conditional.'rust_analyzer_settings == false'] +ignore = ["rust-analyzer.toml"] [hooks] pre = ["switch_nightly_stable.rhai"] diff --git a/rust-analyzer.toml b/rust-analyzer.toml new file mode 100644 index 0000000..9eab123 --- /dev/null +++ b/rust-analyzer.toml @@ -0,0 +1,2 @@ +[rustfmt] +overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"] From d202cad43038971984e9d9c516a067e4939aba4a Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 22:40:57 +0200 Subject: [PATCH 2/8] Update Trunk.toml to reflect never trunk version --- Trunk.toml | 67 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/Trunk.toml b/Trunk.toml index a669c48..b7830c5 100644 --- a/Trunk.toml +++ b/Trunk.toml @@ -1,3 +1,9 @@ +# An example Trunk.toml with all possible fields along with their defaults. +# This file is taken from https://github.com/trunk-rs/trunk/blob/main/Trunk.toml + +# A sem-ver version requirement of trunk required for this project +trunk-version = "*" + [build] # The index HTML file to drive the bundling process. target = "index.html" @@ -14,17 +20,19 @@ filehash = true # Whether to inject scripts (and module preloads) into the finalized output. inject_scripts = true # Run without network access -# offline = false +offline = false # Require Cargo.lock and cache are up to date -# frozen = false +frozen = false # Require Cargo.lock is up to date -# locked = false +locked = false # Control minification -# minify = "never" # can be one of: never, on_release, always +minify = "never" # can be one of: never, on_release, always # Allow disabling sub-resource integrity (SRI) -# no_sri = false +no_sri = false # An optional cargo profile to use # cargo_profile = "release-trunk" +# Allow injecting a nonce attribute +create_nonce = false [watch] # Paths to watch. The `build.target`'s parent folder is watched by default. @@ -40,21 +48,60 @@ port = 3000 # Aliases to serve, typically found in an /etc/hosts file. # aliases = ["http://localhost.mywebsite.com"] # Disable the reverse DNS lookup during startup -# disable_address_lookup = false +disable_address_lookup = false # Open a browser tab once the initial build is complete. open = false # Whether to disable fallback to index.html for missing files. -# no_spa = false +no_spa = false # Disable auto-reload of the web app. -# no_autoreload = false +no_autoreload = false # Disable error reporting -# no_error_reporting = false +no_error_reporting = false # Additional headers set for responses. # headers = { "test-header" = "header value", "test-header2" = "header value 2" } # Protocol used for autoreload WebSockets connection. -# ws_protocol = "ws" +ws_protocol = "ws" # The certificate/private key pair to use for TLS, which is enabled if both are set. # tls_key_path = "self_signed_certs/key.pem" # tls_cert_path = "self_signed_certs/cert.pem" # Additional headers to send. NOTE: header names must be valid HTTP headers. # headers = { "X-Foo" = "bar" } + +[clean] +# The output dir for all final assets. +dist = "dist" +# Optionally perform a cargo clean. +cargo = false + +[tools] +# Default dart-sass version to download. +# sass = "1.69.5" +# Default wasm-bindgen version to download. +# wasm_bindgen = "0.2.89" +# Default wasm-opt version to download. +# wasm_opt = "version_123" +# Default tailwindcss-cli version to download. +# tailwindcss = "3.3.5" + +## proxy +# Proxies are optional, and default to `None`. +# Proxies are only run as part of the `trunk serve` command. + +[[proxy]] +# This WebSocket proxy example has a backend and ws field. This example will listen for +# WebSocket connections at `/api/ws` and proxy them to `ws://localhost:9000/api/ws`. +# backend = "ws://localhost:9000/api/ws" +# ws = true + + +## hooks +# Hooks are optional, and default to `None`. +# Hooks are executed as part of Trunk's main build pipeline, no matter how it is run. + +[[hooks]] +# This hook example shows all the current available fields. It will execute the equivalent of +# typing "echo Hello Trunk!" right at the start of the build process (even before the HTML file +# is read). By default, the command is spawned directly and no shell is used. +# stage = "pre_build" +# command = "echo" +# command_arguments = ["Hello", "Trunk!"] From 7a3bc79a7111e0859ee9b64d40651470718a46de Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 22:44:53 +0200 Subject: [PATCH 3/8] Include default optimizations for development profile --- Cargo.nightly.toml | 9 +++++++++ Cargo.stable.toml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/Cargo.nightly.toml b/Cargo.nightly.toml index c12b5b6..251816e 100644 --- a/Cargo.nightly.toml +++ b/Cargo.nightly.toml @@ -24,6 +24,15 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" web-sys = { version = "0.3", features = ["Document", "Window"] } +[profile.dev] +incremental = true +opt-level = 0 +debug = 1 # Reduce debug info +lto = false + +[profile.dev.package."*"] +opt-level = 3 # optimize dependencies aggressively +debug = 1 # we don’t need much debug info for dependencies [profile.release] opt-level = 'z' diff --git a/Cargo.stable.toml b/Cargo.stable.toml index 72cd0d9..1bbd067 100644 --- a/Cargo.stable.toml +++ b/Cargo.stable.toml @@ -24,6 +24,15 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" web-sys = { version = "0.3", features = ["Document", "Window"] } +[profile.dev] +incremental = true +opt-level = 0 +debug = 1 # Reduce debug info +lto = false + +[profile.dev.package."*"] +opt-level = 3 # optimize dependencies aggressively +debug = 1 # we don’t need much debug info for dependencies [profile.release] opt-level = 'z' From b23c779e4ea18d6a883a2dfa3b44121ac3c847dd Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 22:53:48 +0200 Subject: [PATCH 4/8] Fix: Fallback for 404 not found was not imported --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 923ba7b..658f368 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ mod components; mod pages; // Top-Level pages -use crate::pages::home::Home; +use crate::pages::{home::Home, not_found::NotFound}; /// An app router which renders the homepage and handles 404's #[component] @@ -26,7 +26,7 @@ pub fn App() -> impl IntoView { - + From bd0395c7c09920d10d0bde3ddd5c4c7c47d0049f Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 22:55:01 +0200 Subject: [PATCH 5/8] Fix: Trunk proxy error --- Trunk.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trunk.toml b/Trunk.toml index b7830c5..af1048c 100644 --- a/Trunk.toml +++ b/Trunk.toml @@ -87,7 +87,7 @@ cargo = false # Proxies are optional, and default to `None`. # Proxies are only run as part of the `trunk serve` command. -[[proxy]] +# [[proxy]] # This WebSocket proxy example has a backend and ws field. This example will listen for # WebSocket connections at `/api/ws` and proxy them to `ws://localhost:9000/api/ws`. # backend = "ws://localhost:9000/api/ws" @@ -98,7 +98,7 @@ cargo = false # Hooks are optional, and default to `None`. # Hooks are executed as part of Trunk's main build pipeline, no matter how it is run. -[[hooks]] +# [[hooks]] # This hook example shows all the current available fields. It will execute the equivalent of # typing "echo Hello Trunk!" right at the start of the build process (even before the HTML file # is read). By default, the command is spawned directly and no shell is used. From aef7a4e5e5c68fda74abef3a8099f07182a867f1 Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 23:00:50 +0200 Subject: [PATCH 6/8] Fix: cargo-generate link was pointing to the wrong repository --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee4f8bb..572c612 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ cargo install cargo-generate trunk leptosfmt To set up your project with this template, run ```sh -cargo generate --git https://github.com/leptos-community/start-trunk +cargo generate --git https://github.com/leptos-rs/start-trunk ``` to generate your new project, then From 80fdb59aa89b7d928646b75129a5be3cc2dbc0ff Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 30 Aug 2025 23:23:42 +0200 Subject: [PATCH 7/8] Changed 404 page --- src/pages/not_found.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/not_found.rs b/src/pages/not_found.rs index ab89b42..d545979 100644 --- a/src/pages/not_found.rs +++ b/src/pages/not_found.rs @@ -3,5 +3,8 @@ use leptos::prelude::*; /// 404 Not Found Page #[component] pub fn NotFound() -> impl IntoView { - view! {

"Uh oh!"
"We couldn't find that page!"

} + view! { +

"404: Page not found"

+

"We couldn't find that page!"

+ } } From 9136bc54ad2efd3b950a21d7460619c9ebbc1162 Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 3 Sep 2025 20:26:54 +0200 Subject: [PATCH 8/8] Comment out trunk settings and dev profile optimizations --- Cargo.nightly.toml | 18 +++++++++--------- Cargo.stable.toml | 18 +++++++++--------- Trunk.toml | 24 +++++++++++------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Cargo.nightly.toml b/Cargo.nightly.toml index 251816e..a8b56e0 100644 --- a/Cargo.nightly.toml +++ b/Cargo.nightly.toml @@ -24,15 +24,15 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" web-sys = { version = "0.3", features = ["Document", "Window"] } -[profile.dev] -incremental = true -opt-level = 0 -debug = 1 # Reduce debug info -lto = false - -[profile.dev.package."*"] -opt-level = 3 # optimize dependencies aggressively -debug = 1 # we don’t need much debug info for dependencies +# [profile.dev] +# incremental = true +# opt-level = 0 +# debug = 1 # Reduce debug info +# lto = false + +# [profile.dev.package."*"] +# opt-level = 3 # optimize dependencies aggressively +# debug = 1 # we don’t need much debug info for dependencies [profile.release] opt-level = 'z' diff --git a/Cargo.stable.toml b/Cargo.stable.toml index 1bbd067..9e27f4b 100644 --- a/Cargo.stable.toml +++ b/Cargo.stable.toml @@ -24,15 +24,15 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" web-sys = { version = "0.3", features = ["Document", "Window"] } -[profile.dev] -incremental = true -opt-level = 0 -debug = 1 # Reduce debug info -lto = false - -[profile.dev.package."*"] -opt-level = 3 # optimize dependencies aggressively -debug = 1 # we don’t need much debug info for dependencies +# [profile.dev] +# incremental = true +# opt-level = 0 +# debug = 1 # Reduce debug info +# lto = false + +# [profile.dev.package."*"] +# opt-level = 3 # optimize dependencies aggressively +# debug = 1 # we don’t need much debug info for dependencies [profile.release] opt-level = 'z' diff --git a/Trunk.toml b/Trunk.toml index af1048c..0894efa 100644 --- a/Trunk.toml +++ b/Trunk.toml @@ -20,19 +20,19 @@ filehash = true # Whether to inject scripts (and module preloads) into the finalized output. inject_scripts = true # Run without network access -offline = false +# offline = false # Require Cargo.lock and cache are up to date -frozen = false +# frozen = false # Require Cargo.lock is up to date -locked = false +# locked = false # Control minification -minify = "never" # can be one of: never, on_release, always +# minify = "never" # can be one of: never, on_release, always # Allow disabling sub-resource integrity (SRI) -no_sri = false +# no_sri = false # An optional cargo profile to use # cargo_profile = "release-trunk" # Allow injecting a nonce attribute -create_nonce = false +# create_nonce = false [watch] # Paths to watch. The `build.target`'s parent folder is watched by default. @@ -48,19 +48,19 @@ port = 3000 # Aliases to serve, typically found in an /etc/hosts file. # aliases = ["http://localhost.mywebsite.com"] # Disable the reverse DNS lookup during startup -disable_address_lookup = false +# disable_address_lookup = false # Open a browser tab once the initial build is complete. open = false # Whether to disable fallback to index.html for missing files. -no_spa = false +# no_spa = false # Disable auto-reload of the web app. -no_autoreload = false +# no_autoreload = false # Disable error reporting -no_error_reporting = false +# no_error_reporting = false # Additional headers set for responses. # headers = { "test-header" = "header value", "test-header2" = "header value 2" } # Protocol used for autoreload WebSockets connection. -ws_protocol = "ws" +# ws_protocol = "ws" # The certificate/private key pair to use for TLS, which is enabled if both are set. # tls_key_path = "self_signed_certs/key.pem" # tls_cert_path = "self_signed_certs/cert.pem" @@ -68,8 +68,6 @@ ws_protocol = "ws" # headers = { "X-Foo" = "bar" } [clean] -# The output dir for all final assets. -dist = "dist" # Optionally perform a cargo clean. cargo = false