Skip to content

How to use the assets directory? #2060

Answered by gbj
DenuxPlays asked this question in Q&A
Discussion options

You must be logged in to vote

This kind of depends on how your server is set up exactly.

The cargo-leptos docs say:

# Assets source dir. All files found here will be copied and synchronized to site-root.
assets-dir = "assets"

This means that whatever is in the assets directory will be copied to the site-root -- in the default case, target/site.

Then the server can be set up to server static files from that directory. For example, if I look at the Actix starter template, it serves this site-root directory at /assets:

        App::new()
            .route("/api/{tail:.*}", leptos_actix::handle_server_fns())
            // serve JS/WASM/CSS from `pkg`
            .service(Files::new("/pkg", format!("{site_root}/pkg")))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DenuxPlays
Comment options

Answer selected by DenuxPlays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants