Repository: leptos-rs/leptos
File: leptos_config/src/lib.rs (Rust)

Code before:
    /// The protocol the Websocket watcher uses on the client: `ws` in most cases, `wss` when behind a reverse https proxy.
    /// Defaults to `ws`
    #[builder(default)]
    #[serde(default)]
    pub reload_ws_protocol: ReloadWSProtocol,
    /// The path of a custom 404 Not Found page to display when statically serving content, defaults to `site_root/404.html`
    #[builder(default = default_not_found_path())]
    #[serde(default = "default_not_found_path")]
    pub not_found_path: Arc<str>,
    /// The file name of the hash text file generated by cargo-leptos. Defaults to `hash.txt`.
    #[builder(default = default_hash_file_name())]
    #[serde(default = "default_hash_file_name")]
    pub hash_file: Arc<str>,
    /// If true, hashes will be generated for all files in the site_root and added to their file names.
    /// Defaults to `true`.
    #[builder(default = default_hash_files())]
    #[serde(default = "default_hash_files")]
    pub hash_files: bool,
    #[builder(default, setter(strip_option))]
    #[serde(default)]
    pub server_fn_prefix: Option<String>,
    #[builder(default)]
    #[serde(default)]
    pub disable_server_fn_hash: bool,
}

impl LeptosOptions {
    fn try_from_env() -> Result<Self, LeptosConfigError> {
        let output_name = env_w_default(
            "LEPTOS_OUTPUT_NAME",
            std::option_env!("LEPTOS_OUTPUT_NAME",).unwrap_or_default(),
        )?;
        if output_name.is_empty() {
            eprintln!(
                "It looks like you're trying to compile Leptos without the \
                 LEPTOS_OUTPUT_NAME environment variable being set. There are \
                 two options\n 1. cargo-leptos is not being used, but \
                 get_configuration() is being passed None. This needs to be \
                 changed to Some(\"Cargo.toml\")\n 2. You are compiling \
                 Leptos without LEPTOS_OUTPUT_NAME being set with \
                 cargo-leptos. This shouldn't be possible!"
            );
        }
        Ok(LeptosOptions {
            output_name: output_name.into(),
            site_root: env_w_default("LEPTOS_SITE_ROOT", "target/site")?.into(),
            site_pkg_dir: env_w_default("LEPTOS_SITE_PKG_DIR", "pkg")?.into(),
            env: env_from_str(env_w_default("LEPTOS_ENV", "DEV")?.as_str())?,
            site_addr: env_w_default("LEPTOS_SITE_ADDR", "127.0.0.1:3000")?
                .parse()?,
            reload_port: env_w_default("LEPTOS_RELOAD_PORT", "3001")?

Review comment (suggestion):
`LeptosOptions` should be marked as non-exhaustive so fields can be added without requiring a breaking semver update. However, adding a non-exhaustive annotation is also a breaking change. I’m happy to add it if you want, and if there’s another version bump coming up I can switch this PR to that branch if one exists.

Code after:
    #[serde(default)]
    pub reload_external_port: Option<u32>,
    /// The protocol the Websocket watcher uses on the client: `ws` in most cases, `wss` when behind a reverse https proxy.
    /// Defaults to `ws`
    #[builder(default)]
    #[serde(default)]
    pub reload_ws_protocol: ReloadWSProtocol,
    /// The path of a custom 404 Not Found page to display when statically serving content, defaults to `site_root/404.html`
    #[builder(default = default_not_found_path())]
    #[serde(default = "default_not_found_path")]
    pub not_found_path: Arc<str>,
    /// The file name of the hash text file generated by cargo-leptos. Defaults to `hash.txt`.
    #[builder(default = default_hash_file_name())]
    #[serde(default = "default_hash_file_name")]
    pub hash_file: Arc<str>,
    /// If true, hashes will be generated for all files in the site_root and added to their file names.
    /// Defaults to `true`.
    #[builder(default = default_hash_files())]
    #[serde(default = "default_hash_files")]
    pub hash_files: bool,
    /// The default prefix to use for server functions when generating API routes. Can be
    /// overridden for individual functions using `#[server(prefix = "...")]` as usual.
    ///
    /// This is useful to override the default prefix (`/api`) for all server functions without
    /// needing to manually specify via `#[server(prefix = "...")]` on every server function.
    #[builder(default, setter(strip_option))]
    #[serde(default)]
    pub server_fn_prefix: Option<String>,
    /// Whether to disable appending the server functions' hashes to the end of their API names.
    ///
    /// This is useful when an app's client side needs a stable server API. For example, shipping
    /// the CSR WASM binary in a Tauri app. Tauri app releases are dependent on each platform's
    /// distribution method (e.g., the Apple App Store or the Google Play Store), which typically
    /// are much slower than the frequency at which a website can be updated. In addition, it's
    /// common for users to not have the latest app version installed. In these cases, the CSR WASM
    /// app would need to be able to continue calling the backend server function API, so the API
    /// path needs to be consistent and not have a hash appended.
    ///
    /// Note that the hash suffixes is intended as a way to ensure duplicate API routes are created.
    /// Without the hash, server functions will need to have unique names to avoid creating
    /// duplicate routes. Axum will throw an error if a duplicate route is added to the router, but
    /// Actix will not.
    #[builder(default)]
    #[serde(default)]
    pub disable_server_fn_hash: bool,
    /// Include the module path of the server function in the API route. This is an alternative
    /// strategy to prevent duplicate server function API routes (the default strategy is to add
    /// a hash to the end of the route). Each element of the module path will be separated by a `/`.
    /// For example, a server function with a fully qualified name of `parent::child::server_fn`
    /// would have an API route of `/api/parent/child/server_fn` (possibly with a
    /// different prefix and a hash suffix depending on the values of the other server fn configs).