From a44ff4555b6f08fce20f95ab4fae370012caa0aa Mon Sep 17 00:00:00 2001
From: Greg Burri <greg.burri@gmail.com>
Date: Thu, 10 Sep 2020 19:32:31 +0200
Subject: [PATCH] CSS -> SASS

---
 .gitignore                               |  2 ++
 backend/build.rs                         | 25 ++++++++++++++++++++++++
 conf.ron => backend/conf.ron             |  0
 backend/{static/style.css => style.scss} |  0
 4 files changed, 27 insertions(+)
 create mode 100644 backend/build.rs
 rename conf.ron => backend/conf.ron (100%)
 rename backend/{static/style.css => style.scss} (100%)

diff --git a/.gitignore b/.gitignore
index c41e4eb..e97304b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
 **/*.rs.bk
 key.secret
 WebSharper/key
+backend/static/style.css
+style.css.map
\ No newline at end of file
diff --git a/backend/build.rs b/backend/build.rs
new file mode 100644
index 0000000..ba5da7e
--- /dev/null
+++ b/backend/build.rs
@@ -0,0 +1,25 @@
+/*
+Additionnal build, doc: https://doc.rust-lang.org/cargo/reference/build-scripts.html
+
+What is build here:
+ - Compile the SASS file to CSS file.
+*/
+
+use std::process::Command;
+
+fn main() {
+    println!("cargo:rerun-if-changed=style.scss");
+
+    let output =
+        Command::new("sass")
+            .arg("./style.scss")
+            .arg("./static/style.css")
+            .output()
+            .expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/");
+
+    if !output.status.success() {
+        //panic!("Unable to compile SASS file, install SASS, see https://sass-lang.com/")
+        let error = std::fs::read_to_string("./static/style.css").expect("unable to read style.css");
+        panic!(error);
+    }
+}
diff --git a/conf.ron b/backend/conf.ron
similarity index 100%
rename from conf.ron
rename to backend/conf.ron
diff --git a/backend/static/style.css b/backend/style.scss
similarity index 100%
rename from backend/static/style.css
rename to backend/style.scss
-- 
2.49.0