Fix css hot reload

This commit is contained in:
Florian RICHER 2024-01-07 00:23:12 +01:00
parent 315474b708
commit cf65d5b8e9
3 changed files with 9 additions and 0 deletions

View file

@ -100,7 +100,9 @@ opt-level = 'z'
name = "portfolio"
site-root = "target/site"
site-pkg-dir = "pkg"
style-file = "style/main.scss" # Important for Hot Reload to work properly (File must exist)
tailwind-input-file = "style/portfolio.css"
watch-additional-files = ["data_src"]
assets-dir = "public"
site-addr = "127.0.0.1:3000"
reload-port = 3001

View file

@ -10,6 +10,12 @@ cfg_if! {
use leptos_actix::{generate_route_list, LeptosRoutes};
use simple_logger::SimpleLogger;
#[get("/style.css")]
async fn css() -> impl Responder {
actix_files::NamedFile::open_async("./style/output.css").await
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
// Configure logger
@ -38,6 +44,7 @@ cfg_if! {
.app_data(web::Data::clone(&data)) // Must panic if data can't be loaded
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
.leptos_routes(leptos_options.to_owned(), routes.to_owned(), || view! { <App/> })
.service(css)
.service(Files::new("/", site_root))
.wrap(middleware::Compress::default())
})

0
style/main.scss Normal file
View file