@prospective.co/procss 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib.rs +5 -1
- package/src/transformers/inline_url.rs +10 -3
- package/src/utils.rs +2 -0
- package/target/cjs/procss_bg.wasm +0 -0
- package/target/esm/procss_bg.wasm +0 -0
package/package.json
CHANGED
package/src/lib.rs
CHANGED
|
@@ -28,9 +28,14 @@ fn parse_url(input: &str) -> nom::IResult<&str, &str> {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
fn into_data_uri<'a>(path: &Path) -> Cow<'a, str> {
|
|
31
|
-
let contents = fs::
|
|
31
|
+
let contents = fs::read(path).expect("Error reading file");
|
|
32
32
|
let encoded = base64::encode(contents);
|
|
33
|
-
|
|
33
|
+
let fff = path.extension().unwrap_or_default().to_string_lossy();
|
|
34
|
+
let fmt = match fff.as_ref() {
|
|
35
|
+
"png" => "png",
|
|
36
|
+
_ => "svg+xml",
|
|
37
|
+
};
|
|
38
|
+
format!("url(\"data:image/{};base64,{}\")", fmt, encoded).into()
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
fn inline_url_impl<'a>(newpath: &str, flat: &mut Css<'a>) {
|
|
@@ -40,7 +45,9 @@ fn inline_url_impl<'a>(newpath: &str, flat: &mut Css<'a>) {
|
|
|
40
45
|
.and_then(|x| x.0.is_empty().then_some(Path::new(newpath).join(x.1)));
|
|
41
46
|
|
|
42
47
|
if let Some(path) = &path {
|
|
43
|
-
|
|
48
|
+
if path.starts_with(".") || path.starts_with("/") {
|
|
49
|
+
rule.value = into_data_uri(path);
|
|
50
|
+
}
|
|
44
51
|
}
|
|
45
52
|
})
|
|
46
53
|
}
|
package/src/utils.rs
CHANGED
|
Binary file
|
|
Binary file
|