Crate fervid_css
source ·Expand description
Style transformer for Vue <style>
blocks
Example
use swc_core::common::{Span, BytePos};
let input = r#"
.example {
background: #ff0;
}
"#;
// Note: `Span` usually comes from the input, e.g. from `<style>` block
let span = Span::new(
BytePos(1),
BytePos(1 + input.len() as u32),
Default::default(),
);
let mut errors = Vec::new();
let result = fervid_css::transform_css(input, span, Some("data-v-abcd1234"), &mut errors, Default::default());
if let Some(transformed_css) = result {
assert_eq!(".example[data-v-abcd1234]{background:#ff0}", transformed_css);
}
Structs
Enums
Functions
- Parses the
input
asStylesheet
- Stringifies the
Stylesheet
- Transforms raw CSS, also handles the scopes.