diff options
author | Lukas Stabe <lukas@stabe.de> | 2020-09-26 21:07:24 +0000 |
---|---|---|
committer | Lukas Stabe <lukas@stabe.de> | 2020-09-26 21:07:24 +0000 |
commit | f8b74203b7457fbf0482ec9e10266b370b1bfeab (patch) | |
tree | fe938c009d892bf31853a50eb9f190b80276e4f3 | |
parent | remove stylelint again and fix a few css issues (diff) | |
download | miniserve-f8b74203b7457fbf0482ec9e10266b370b1bfeab.tar.gz miniserve-f8b74203b7457fbf0482ec9e10266b370b1bfeab.zip |
compile scss at build time
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | build.rs | 13 | ||||
-rw-r--r-- | src/main.rs | 7 |
4 files changed, 18 insertions, 8 deletions
@@ -1716,7 +1716,6 @@ dependencies = [ "futures", "grass", "hex", - "lazy_static", "libflate", "log", "maud", @@ -46,8 +46,6 @@ actix-multipart = "0.3.0" actix-rt = "1.1.1" actix-web-httpauth = "0.5.0" mime = "0.3" -grass = "0.10.3" -lazy_static = "1.4.0" [dev-dependencies] assert_cmd = "1.0" @@ -58,3 +56,6 @@ rstest = "0.6" regex = "1.3.9" pretty_assertions = "0.6" url = "2.1" + +[build-dependencies] +grass = "0.10.3" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c759316 --- /dev/null +++ b/build.rs @@ -0,0 +1,13 @@ +use std::env; +use std::fs; +use std::path::Path; + +fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("style.css"); + fs::write( + &dest_path, + grass::from_string(include_str!("data/style.scss").to_string(), &grass::Options::default()).unwrap() + ).unwrap(); + println!("cargo:rerun-if-changed=data/style.css"); +} diff --git a/src/main.rs b/src/main.rs index 22d5f6a..2886a2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -388,12 +388,9 @@ async fn favicon() -> impl Responder { .message_body(logo.into()) } -lazy_static::lazy_static! { - static ref CSS_TEXT: String = grass::from_string(include_str!("../data/style.scss").to_string(), &grass::Options::default()).unwrap(); -} - async fn css() -> impl Responder { + let css = include_str!(concat!(env!("OUT_DIR"), "/style.css")); web::HttpResponse::Ok() .set(ContentType(mime::TEXT_CSS)) - .body(&*CSS_TEXT) + .message_body(css.into()) } |