wip: change assets handling to vite-rs

This commit is contained in:
Alexander Navarro 2025-04-17 16:48:46 -04:00
parent 6cf98d1f1a
commit adbade7411
26 changed files with 761 additions and 112 deletions

View file

@ -3,7 +3,8 @@
use axum_htmx::AutoVaryLayer;
use compendium::config::Config;
use compendium::{config, router, AppState, Error, Link, Result, Tx};
use compendium::static_assets::Assets;
use compendium::{config, router, AppState, Error, Result, Tx};
use minijinja::{Environment, Value};
use sqlx::postgres::PgPoolOptions;
use sqlx::PgPool;
@ -16,6 +17,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
#[tokio::main]
async fn main() -> Result<()> {
let config = Config::new("./config.toml".into())?;
let assets = Assets::new();
// Logs
tracing_subscriber::registry()
@ -27,10 +29,6 @@ async fn main() -> Result<()> {
.with(tracing_subscriber::fmt::layer())
.init();
let mut tmpl_env = Environment::new();
minijinja_embed::load_templates!(&mut tmpl_env);
info!("Connecting to database {}", config.db);
let pool = PgPoolOptions::new()
@ -46,7 +44,7 @@ async fn main() -> Result<()> {
.layer(TraceLayer::new_for_http().on_request(()))
.layer(tx_layer)
.layer(AutoVaryLayer)
.with_state(AppState::new(tmpl_env, tx_state));
.with_state(AppState::new(assets, tx_state));
// Add hot reload only on dev mode
#[cfg(debug_assertions)]