pub struct HtmlIntegration { /* private fields */ }Expand description
HTML integration.
Builds links, preloads for specified chunks.
// Create `HtmlIntegration` struct:
let html = HtmlIntegration::new(MyViteStatic.boxed())
// import all required chunks:
.import("src/entry1.js")
.import("src/entry2.js")
// and then, you can build `String` of HTML (tags, joined by '\n')
.build();
// or you can build array of tags/lines
// .build_lines();
// The result will contain `<script>` tags, `<link>` for CSS and `<link>` preloads for dependencies.Implementations§
Source§impl HtmlIntegration
impl HtmlIntegration
Sourcepub fn new(manifest: Box<dyn Manifest<'static>>) -> Self
pub fn new(manifest: Box<dyn Manifest<'static>>) -> Self
Create new HtmlIntegration builder.
Takes boxed Manifest and returns HtmlIntegration.
Sourcepub fn import(self, chunk: &str) -> Self
pub fn import(self, chunk: &str) -> Self
Import ManifestChunk by key (input filename).
.import("src/this-chunk.js")
.import("src/components/MyCoolComponent.tsx")
.import("src/or/some/styles.scss")§Panics
This function will panic if:
- Failed to find chunk by specified key
- Failed to find dependency (AKA imported chunk)
Sourcepub fn build_lines(self) -> Vec<String>
pub fn build_lines(self) -> Vec<String>
Builds HTML and returns array of lines.
let html_lines = HtmlIntegration::new(MyViteStatic.boxed())
.import("src/entry1.js")
.build_lines();
assert_eq!(html_lines.len(), 2); // `src/entry1.js` script tag AND `src/shared.js` preloadTrait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HtmlIntegration
impl !Send for HtmlIntegration
impl !Sync for HtmlIntegration
impl !UnwindSafe for HtmlIntegration
impl Freeze for HtmlIntegration
impl Unpin for HtmlIntegration
impl UnsafeUnpin for HtmlIntegration
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
Mutably borrows from an owned value. Read more