pub struct ViteConfig<'a> {
pub manifest_path: Option<&'a str>,
pub entrypoints: Option<Vec<&'a str>>,
pub force_mode: Option<ViteMode>,
pub use_heart_beat_check: bool,
pub heart_beat_retries_limit: Option<u8>,
pub enable_dev_server: bool,
pub server_host: Option<&'a str>,
pub prefix: Option<&'a str>,
pub app_url: Option<&'a str>,
}Fields§
§manifest_path: Option<&'a str>The path/to/manifest.json file.
Currently, Vite won’t resolve relative paths, so please consider
your current working directory as the root of it and start the path
with a root node directory directly.
Optionally and experimentally, you can use the [resolve_path]
method for the manifest file resolution. However, this method might
come to fail at some point, and will also panic in the many situations
described on its documentation.
§Example
your_project/
|-- public/
| |-- dist/
| | |-- manifest.json
|-- src/
| |-- main.rs // <-- you're here!
use vite_rust::{ViteConfig, utils::resolve_path};
let config = ViteConfig {
manifest_path: Some("public/dist/manifest.json"),
// or
manifest_path: Some(resolve_path(file!(), "../public/dist/manifest.json")),
// ...
};entrypoints: Option<Vec<&'a str>>Defines which entrypoints Vite will use to generate the html script,
link and stylesheet tags.
If None is provided, Vite will scan the manifest for files with
isEntry: true property and consider them the entrypoints.
force_mode: Option<ViteMode>If None is provided, Vite will discover which one to use considering:
- any of
RUST_ENV,NODE_ENVorAPP_ENVenvironment variables exists and is set totrue; - Dev-server is running;
- Heart beat check is enabled.
By setting this option, the discovering phase will be skipped.
Refer to the crate’s README.md file to understand the way it decides which mode to pick.
use_heart_beat_check: boolWhether Vite should ping your vite dev-server to check if its running.
If false, ViteMode will be set to Development if not forced by the configuration.
heart_beat_retries_limit: Option<u8>How many times heartbeat checker should try before fallbacking.
enable_dev_server: boolWhether dev server should be considered or not.
If false, force_mode should be either Manifest or None,
otherwise, undefined behavior might occur.
server_host: Option<&'a str>The host in which your vite dev-server is running.
Normally, it would be "http://localhost:5173".
Please, do not forget the protocol (http, https)!
prefix: Option<&'a str>Prefix assets path with the given str.
app_url: Option<&'a str>Add a custom domain to prefix every asset URL with.
Implementations§
Source§impl<'a> ViteConfig<'a>
impl<'a> ViteConfig<'a>
Sourcepub fn new(manifest_path: &'a str, entrypoints: Vec<&'a str>) -> Self
pub fn new(manifest_path: &'a str, entrypoints: Vec<&'a str>) -> Self
Creates a new ViteConfig instance with manifest_path and entrypoints fields set.
pub fn set_manifest_path(self, manifest_path: &'a str) -> Self
pub fn set_entrypoints(self, entrypoints: Vec<&'a str>) -> Self
pub fn set_force_mode(self, mode: ViteMode) -> Self
pub fn set_server_host(self, server_host: &'a str) -> Self
pub fn set_heart_beat_retries_limit(self, limit: u8) -> Self
pub fn without_heart_beat_check(self) -> Self
pub fn without_dev_server(self) -> Self
pub fn set_prefix(self, prefix: &'a str) -> Self
pub fn set_app_url(self, app_url: &'a str) -> Self
Trait Implementations§
Source§impl<'a> Clone for ViteConfig<'a>
impl<'a> Clone for ViteConfig<'a>
Source§fn clone(&self) -> ViteConfig<'a>
fn clone(&self) -> ViteConfig<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for ViteConfig<'a>
impl<'a> Debug for ViteConfig<'a>
Source§impl Default for ViteConfig<'_>
impl Default for ViteConfig<'_>
Source§fn default() -> Self
fn default() -> Self
Create a ViteConfig instance.
You can create your config by directly instantiating the struct, or by using some default options. Note that you must set the manifest path.
§Example
use vite_rust::ViteConfig;
let manual_config = ViteConfig {
manifest_path: Some("path/to/manifest.json"),
entrypoints: None, // Vite can discover them by itself
force_mode: None, // Vite can discover it too
use_heart_beat_check: true,
enable_dev_server: true,
server_host: Some("http://localhost:5173"),
heart_beat_retries_limit: Some(5),
prefix: None,
app_url: None,
};
let with_defaults_config = ViteConfig::default().set_manifest_path("path/to/manifest.json");
assert_eq!(manual_config, with_defaults_config);Source§impl<'a> PartialEq for ViteConfig<'a>
impl<'a> PartialEq for ViteConfig<'a>
impl<'a> Eq for ViteConfig<'a>
impl<'a> StructuralPartialEq for ViteConfig<'a>
Auto Trait Implementations§
impl<'a> Freeze for ViteConfig<'a>
impl<'a> RefUnwindSafe for ViteConfig<'a>
impl<'a> Send for ViteConfig<'a>
impl<'a> Sync for ViteConfig<'a>
impl<'a> Unpin for ViteConfig<'a>
impl<'a> UnwindSafe for ViteConfig<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.