Replace libsass by grass

Closes #1535
Closes #2022
This commit is contained in:
Vincent Prouillet 2023-01-08 23:05:13 +01:00 committed by Vincent Prouillet
parent c22ee676d3
commit fcbb21abca
7 changed files with 203 additions and 168 deletions

View File

@ -18,6 +18,7 @@
- Add new flag 'port_append' to give the ability to remove port from base url - Add new flag 'port_append' to give the ability to remove port from base url
- `config.markdown` is now available in templates - `config.markdown` is now available in templates
- Add `preserve_dotfiles_in_output` option in the config - Add `preserve_dotfiles_in_output` option in the config
- Replace libsass by a Rust implementation: [grass](https://github.com/connorskees/grass)
## 0.16.1 (2022-08-14) ## 0.16.1 (2022-08-14)

251
Cargo.lock generated
View File

@ -8,6 +8,17 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.8",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.2" version = "0.8.2"
@ -129,18 +140,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitvec"
version = "0.19.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.7.3" version = "0.7.3"
@ -183,6 +182,16 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bstr"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b"
dependencies = [
"memchr",
"serde",
]
[[package]] [[package]]
name = "build_const" name = "build_const"
version = "0.2.2" version = "0.2.2"
@ -391,6 +400,12 @@ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
[[package]]
name = "codemap"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24"
[[package]] [[package]]
name = "codespan-reporting" name = "codespan-reporting"
version = "0.11.1" version = "0.11.1"
@ -438,9 +453,9 @@ dependencies = [
[[package]] [[package]]
name = "console" name = "console"
version = "0.15.3" version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5556015fe3aad8b968e5d4124980fbe2f6aaee7aeec6b749de1faaa2ca5d0a4c" checksum = "c9b6515d269224923b26b5febea2ed42b2d5f2ce37284a4dd670fedd6cb8347a"
dependencies = [ dependencies = [
"encode_unicode", "encode_unicode",
"lazy_static", "lazy_static",
@ -573,13 +588,13 @@ dependencies = [
[[package]] [[package]]
name = "css-minify" name = "css-minify"
version = "0.2.2" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692b185e3b7c9af96b3195f3021f53a931d896968ed2ad3fb1cdb6558b30c9ab" checksum = "874c6e2d19f8d4a285083b11a3241bfbe01ac3ed85f26e1e6b34888d960552bd"
dependencies = [ dependencies = [
"derive_more", "derive_more",
"indexmap", "indexmap",
"nom 6.1.2", "nom 7.1.2",
] ]
[[package]] [[package]]
@ -588,7 +603,7 @@ version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
dependencies = [ dependencies = [
"bstr", "bstr 0.2.17",
"csv-core", "csv-core",
"itoa 0.4.8", "itoa 0.4.8",
"ryu", "ryu",
@ -616,9 +631,9 @@ dependencies = [
[[package]] [[package]]
name = "cxx" name = "cxx"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579"
dependencies = [ dependencies = [
"cc", "cc",
"cxxbridge-flags", "cxxbridge-flags",
@ -628,9 +643,9 @@ dependencies = [
[[package]] [[package]]
name = "cxx-build" name = "cxx-build"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70"
dependencies = [ dependencies = [
"cc", "cc",
"codespan-reporting", "codespan-reporting",
@ -643,15 +658,15 @@ dependencies = [
[[package]] [[package]]
name = "cxxbridge-flags" name = "cxxbridge-flags"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c"
[[package]] [[package]]
name = "cxxbridge-macro" name = "cxxbridge-macro"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -985,12 +1000,6 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "funty"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]] [[package]]
name = "futf" name = "futf"
version = "0.1.5" version = "0.1.5"
@ -1123,18 +1132,18 @@ dependencies = [
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]] [[package]]
name = "globset" name = "globset"
version = "0.4.9" version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"bstr", "bstr 1.1.0",
"fnv", "fnv",
"log", "log",
"regex", "regex",
@ -1151,6 +1160,29 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "grass"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a906155472dc29adcaa55888a08b814ac916f667ceb5b8dda0af4785f503c75f"
dependencies = [
"grass_compiler",
]
[[package]]
name = "grass_compiler"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb28d0ff27bf64c29d78e10ed1e3c3833ca1c92f06bd85321adb499abf5c7f57"
dependencies = [
"codemap",
"indexmap",
"lasso",
"once_cell",
"phf 0.10.1",
"rand 0.8.5",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.15" version = "0.3.15"
@ -1179,6 +1211,15 @@ dependencies = [
"crunchy", "crunchy",
] ]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.12.3"
@ -1355,11 +1396,10 @@ dependencies = [
[[package]] [[package]]
name = "ignore" name = "ignore"
version = "0.4.18" version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" checksum = "a05705bc64e0b66a806c3740bd6578ea66051b157ec42dc219c785cbf185aef3"
dependencies = [ dependencies = [
"crossbeam-utils",
"globset", "globset",
"lazy_static", "lazy_static",
"log", "log",
@ -1410,7 +1450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown 0.12.3",
] ]
[[package]] [[package]]
@ -1435,11 +1475,11 @@ dependencies = [
[[package]] [[package]]
name = "insta" name = "insta"
version = "1.23.0" version = "1.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e48b08a091dfe5b09a6a9688c468fdd5b4396e92ce09e2eb932f0884b02788a4" checksum = "f6f0f08b46e4379744de2ab67aa8f7de3ffd1da3e275adc41fcc82053ede46ff"
dependencies = [ dependencies = [
"console 0.15.3", "console 0.15.4",
"lazy_static", "lazy_static",
"linked-hash-map", "linked-hash-map",
"similar", "similar",
@ -1476,9 +1516,9 @@ dependencies = [
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.7.0" version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
@ -1512,7 +1552,7 @@ checksum = "37228e06c75842d1097432d94d02f37fe3ebfca9791c2e8fef6e9db17ed128c1"
dependencies = [ dependencies = [
"cedarwood", "cedarwood",
"fxhash", "fxhash",
"hashbrown", "hashbrown 0.12.3",
"lazy_static", "lazy_static",
"phf 0.11.1", "phf 0.11.1",
"phf_codegen 0.11.1", "phf_codegen 0.11.1",
@ -1565,6 +1605,15 @@ dependencies = [
"winapi-build", "winapi-build",
] ]
[[package]]
name = "lasso"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb7b21a526375c5ca55f1a6dfd4e1fad9fa4edd750f530252a718a44b2608f0"
dependencies = [
"hashbrown 0.11.2",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -1615,7 +1664,7 @@ checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
name = "libs" name = "libs"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ahash", "ahash 0.8.2",
"ammonia", "ammonia",
"atty", "atty",
"base64", "base64",
@ -1625,6 +1674,7 @@ dependencies = [
"gh-emoji", "gh-emoji",
"glob", "glob",
"globset", "globset",
"grass",
"image", "image",
"lexical-sort", "lexical-sort",
"minify-html", "minify-html",
@ -1638,7 +1688,6 @@ dependencies = [
"regex", "regex",
"relative-path", "relative-path",
"reqwest", "reqwest",
"sass-rs",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"sha2", "sha2",
@ -1975,27 +2024,34 @@ dependencies = [
[[package]] [[package]]
name = "minify-html" name = "minify-html"
version = "0.10.3" version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58f84854d62363972a73c3d8331b85a479366a0871a83f2a01ac11b9ba787c10" checksum = "5d2d0e6da317b10501ed44ebe2aa59c3926890a6dd2a0a77d069e5e9ea69b5c0"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"css-minify", "css-minify",
"lazy_static", "lazy_static",
"memchr", "memchr",
"minify-js", "minify-js",
"rustc-hash",
] ]
[[package]] [[package]]
name = "minify-js" name = "minify-js"
version = "0.2.9" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe033709f5a1159736cf7e22748518ffb75af26f3a6264d52ecc8bb38c68c36" checksum = "58a1566cb31504e32f009f6c47ad83f7eeb91d00e8e9845314f1d0b2202ef595"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"parse-js", "parse-js",
] ]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.6.2" version = "0.6.2"
@ -2153,15 +2209,12 @@ dependencies = [
[[package]] [[package]]
name = "nom" name = "nom"
version = "6.1.2" version = "7.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c"
dependencies = [ dependencies = [
"bitvec",
"funty",
"lexical-core",
"memchr", "memchr",
"version_check", "minimal-lexical",
] ]
[[package]] [[package]]
@ -2417,9 +2470,9 @@ dependencies = [
[[package]] [[package]]
name = "parse-js" name = "parse-js"
version = "0.3.1" version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66bb85ec60d22b9e6d4adac1e3dbdaf3903a4485f476c5f4dd7ed1285cbf4dad" checksum = "30534759e6ad87aa144c396544747e1c25b1020bd133356fd758c8facec764e5"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"lazy_static", "lazy_static",
@ -2503,7 +2556,9 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [ dependencies = [
"phf_macros",
"phf_shared 0.10.0", "phf_shared 0.10.0",
"proc-macro-hack",
] ]
[[package]] [[package]]
@ -2555,6 +2610,20 @@ dependencies = [
"rand 0.8.5", "rand 0.8.5",
] ]
[[package]]
name = "phf_macros"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0"
dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "phf_shared" name = "phf_shared"
version = "0.10.0" version = "0.10.0"
@ -2674,6 +2743,12 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.49" version = "1.0.49"
@ -2736,12 +2811,6 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "radium"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.7.3" version = "0.7.3"
@ -2958,6 +3027,12 @@ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"
@ -3023,28 +3098,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "sass-rs"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cabcf7c6e55053f359911187ac401409aad2dc14338cae972dec266fee486abd"
dependencies = [
"libc",
"sass-sys",
]
[[package]]
name = "sass-sys"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "933bca23b402377f0ab71e79732a826deffc748013746ac3314f6abc7f9fc51c"
dependencies = [
"cc",
"libc",
"num_cpus",
"pkg-config",
]
[[package]] [[package]]
name = "schannel" name = "schannel"
version = "0.1.20" version = "0.1.20"
@ -3377,12 +3430,6 @@ dependencies = [
"yaml-rust", "yaml-rust",
] ]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "tar" name = "tar"
version = "0.4.38" version = "0.4.38"
@ -3597,9 +3644,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.23.0" version = "1.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes 1.3.0", "bytes 1.3.0",
@ -3684,9 +3731,9 @@ dependencies = [
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.3" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]] [[package]]
name = "typenum" name = "typenum"
@ -4203,12 +4250,6 @@ dependencies = [
"winapi-build", "winapi-build",
] ]
[[package]]
name = "wyz"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
[[package]] [[package]]
name = "xattr" name = "xattr"
version = "0.2.3" version = "0.2.3"

View File

@ -27,7 +27,7 @@ rayon = "1"
regex = "1" regex = "1"
relative-path = "1" relative-path = "1"
reqwest = { version = "0.11", default-features = false, features = ["blocking"] } reqwest = { version = "0.11", default-features = false, features = ["blocking"] }
sass-rs = "0.2" grass = {version = "0.12.1", default-features = false, features = ["random"]}
serde_json = "1" serde_json = "1"
serde_yaml = "0.9" serde_yaml = "0.9"
sha2 = "0.10" sha2 = "0.10"

View File

@ -14,6 +14,7 @@ pub use filetime;
pub use gh_emoji; pub use gh_emoji;
pub use glob; pub use glob;
pub use globset; pub use globset;
pub use grass;
pub use image; pub use image;
pub use lexical_sort; pub use lexical_sort;
pub use minify_html; pub use minify_html;
@ -27,7 +28,6 @@ pub use rayon;
pub use regex; pub use regex;
pub use relative_path; pub use relative_path;
pub use reqwest; pub use reqwest;
pub use sass_rs;
pub use serde_json; pub use serde_json;
pub use serde_yaml; pub use serde_yaml;
pub use sha2; pub use sha2;

View File

@ -2,13 +2,14 @@ use std::fs::create_dir_all;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use libs::globset::Glob; use libs::globset::Glob;
use libs::sass_rs::{compile_file, Options, OutputStyle}; use libs::grass::{from_path as compile_file, Options, OutputStyle};
use libs::walkdir::{DirEntry, WalkDir}; use libs::walkdir::{DirEntry, WalkDir};
use crate::anyhow; use crate::anyhow;
use errors::{bail, Result}; use errors::{bail, Result};
use utils::fs::{create_file, ensure_directory_exists}; use utils::fs::{create_file, ensure_directory_exists};
pub fn compile_sass(base_path: &Path, output_path: &Path) -> Result<()> { pub fn compile_sass(base_path: &Path, output_path: &Path) -> Result<()> {
ensure_directory_exists(output_path)?; ensure_directory_exists(output_path)?;
@ -18,11 +19,24 @@ pub fn compile_sass(base_path: &Path, output_path: &Path) -> Result<()> {
sass_path sass_path
}; };
let mut options = Options { output_style: OutputStyle::Compressed, ..Default::default() }; let options = Options::default().style(OutputStyle::Compressed);
let mut compiled_paths = compile_sass_glob(&sass_path, output_path, "scss", &options)?; let files = get_non_partial_scss(&sass_path);
let mut compiled_paths = Vec::new();
options.indented_syntax = true; for file in files {
compiled_paths.extend(compile_sass_glob(&sass_path, output_path, "sass", &options)?); let css = compile_file(&file, &options).map_err(|e| anyhow!(e))?;
let path_inside_sass = file.strip_prefix(&sass_path).unwrap();
let parent_inside_sass = path_inside_sass.parent();
let css_output_path = output_path.join(path_inside_sass).with_extension("css");
if parent_inside_sass.is_some() {
create_dir_all(css_output_path.parent().unwrap())?;
}
create_file(&css_output_path, &css)?;
compiled_paths.push((path_inside_sass.to_owned(), css_output_path));
}
compiled_paths.sort(); compiled_paths.sort();
for window in compiled_paths.windows(2) { for window in compiled_paths.windows(2) {
@ -39,40 +53,12 @@ pub fn compile_sass(base_path: &Path, output_path: &Path) -> Result<()> {
Ok(()) Ok(())
} }
fn compile_sass_glob(
sass_path: &Path,
output_path: &Path,
extension: &str,
options: &Options,
) -> Result<Vec<(PathBuf, PathBuf)>> {
let files = get_non_partial_scss(sass_path, extension);
let mut compiled_paths = Vec::new();
for file in files {
let css = compile_file(&file, options.clone()).map_err(|e| anyhow!(e))?;
let path_inside_sass = file.strip_prefix(sass_path).unwrap();
let parent_inside_sass = path_inside_sass.parent();
let css_output_path = output_path.join(path_inside_sass).with_extension("css");
if parent_inside_sass.is_some() {
create_dir_all(css_output_path.parent().unwrap())?;
}
create_file(&css_output_path, &css)?;
compiled_paths.push((path_inside_sass.to_owned(), css_output_path));
}
Ok(compiled_paths)
}
fn is_partial_scss(entry: &DirEntry) -> bool { fn is_partial_scss(entry: &DirEntry) -> bool {
entry.file_name().to_str().map(|s| s.starts_with('_')).unwrap_or(false) entry.file_name().to_str().map(|s| s.starts_with('_')).unwrap_or(false)
} }
fn get_non_partial_scss(sass_path: &Path, extension: &str) -> Vec<PathBuf> { fn get_non_partial_scss(sass_path: &Path) -> Vec<PathBuf> {
let glob_string = format!("*.{}", extension); let glob = Glob::new("*.{sass,scss}").expect("Invalid glob for sass").compile_matcher();
let glob = Glob::new(glob_string.as_str()).expect("Invalid glob for sass").compile_matcher();
WalkDir::new(sass_path) WalkDir::new(sass_path)
.into_iter() .into_iter()
@ -83,31 +69,37 @@ fn get_non_partial_scss(sass_path: &Path, extension: &str) -> Vec<PathBuf> {
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }
#[test] #[cfg(test)]
fn test_get_non_partial_scss() { mod tests {
use std::env; use super::*;
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf(); #[test]
path.push("test_site"); fn test_get_non_partial_scss() {
path.push("sass"); use std::env;
let result = get_non_partial_scss(&path, "scss"); let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
path.push("test_site");
path.push("sass");
assert!(!result.is_empty()); let result = get_non_partial_scss(&path);
assert!(result.iter().filter_map(|path| path.file_name()).any(|file| file == "scss.scss"))
} assert!(!result.is_empty());
#[test] assert!(result.iter().filter_map(|path| path.file_name()).any(|file| file == "scss.scss"))
fn test_get_non_partial_scss_underscores() { }
use std::env;
#[test]
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf(); fn test_get_non_partial_scss_underscores() {
path.push("test_site"); use std::env;
path.push("_dir_with_underscores");
path.push(".."); let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
path.push("sass"); path.push("test_site");
path.push("_dir_with_underscores");
let result = get_non_partial_scss(&path, "scss"); path.push("..");
path.push("sass");
assert!(!result.is_empty());
assert!(result.iter().filter_map(|path| path.file_name()).any(|file| file == "scss.scss")) let result = get_non_partial_scss(&path);
assert!(!result.is_empty());
assert!(result.iter().filter_map(|path| path.file_name()).any(|file| file == "scss.scss"))
}
} }

View File

@ -11,7 +11,8 @@ may be of interest:
* The [official Sass website](https://sass-lang.com/) * The [official Sass website](https://sass-lang.com/)
* [Why Sass?](https://alistapart.com/article/why-sass), by Dan Cederholm * [Why Sass?](https://alistapart.com/article/why-sass), by Dan Cederholm
It currently uses a wrapper around LibSass 3.6.4. It currently uses [grass](https://github.com/connorskees/grass), a Rust implementation of Sass roughly equivalent
with dart-sass.
## Using Sass in Zola ## Using Sass in Zola

View File

@ -60,7 +60,7 @@ This will create a shortcode `books` with the argument `path` pointing to a `.to
titles and descriptions. They will flow with the rest of the document in which `books` is called. titles and descriptions. They will flow with the rest of the document in which `books` is called.
Shortcodes are rendered before the page's Markdown is parsed so they don't have access to the page's table of contents. Shortcodes are rendered before the page's Markdown is parsed so they don't have access to the page's table of contents.
Because of that, you also cannot use the [`get_page`](@/documentation/templates/overview.md#get-page)/[`get_section`](@/documentation/templates/overview.md#get-section)/[`get_taxonomy`](@/documentation/templates/overview.md#get-taxonomy)/[`get_taxonomy_term`](@/documentation/templates/overview.md#get-term) global functions. It might work while Because of that, you also cannot use the [`get_page`](@/documentation/templates/overview.md#get-page)/[`get_section`](@/documentation/templates/overview.md#get-section)/[`get_taxonomy`](@/documentation/templates/overview.md#get-taxonomy)/[`get_taxonomy_term`](@/documentation/templates/overview.md#get-taxonomy-term) global functions. It might work while
running `zola serve` because it has been loaded but it will fail during `zola build`. running `zola serve` because it has been loaded but it will fail during `zola build`.
## Using shortcodes ## Using shortcodes