Crates.io | sass-rocket-fairing |
lib.rs | sass-rocket-fairing |
version | 0.2.0 |
source | src |
created_at | 2021-07-10 22:36:26.315256 |
updated_at | 2022-07-14 23:07:51.793652 |
description | A rocket fairing to compile sass files automagically on change ✨ |
homepage | |
repository | https://github.com/SyedAhkam/sass-rocket-fairing |
max_upload_size | |
id | 421230 |
size | 59,865 |
sass-rocket-fairing
is a Fairing/middleware for rocket.rs facilitating sass compilation. It compiles your sass files on change automagically ✨
Powered by rsass (Sass reimplementation in Rust) under the hood.
Add the following to your Cargo.toml file
sass-rocket-fairing = "0.2"
OR using git
sass-rocket-fairing = {version = "0.2", git="https://github.com/SyedAhkam/sass-rocket-fairing.git"}
#[macro_use]
extern crate rocket;
use sass_rocket_fairing::SassFairing;
#[launch]
fn rocket() -> _ {
rocket::build().attach(SassFairing::default())
}
SassFairing
takes advantage of rocket's advanced configuration system. There are two ways to configure it.
Add a Rocket.toml file in root directory of your crate and add the following to it:
[default]
sass_dir = "static/sass"
css_dir = "static/css"
Set the following environment variables:
sass_dir
is the folder where your sass files are to be located.
css_dir
is where your built css files are to be located.
You can change the output format of the css files by setting the format
parameter while creating a new SassFairing
.
rsass
have been re-exported for convenience.
#[macro_use]
extern crate rocket;
use sass_rocket_fairing::{SassFairing, rsass};
#[launch]
fn rocket() -> _ {
rocket::build()
.attach(SassFairing::new(rsass::output::Format {
style: output::Style::Compressed,
.. Default::default()
}
)
)
}
I've stolen a big chunk of code from rocket_dyn_templates and adapted it to my needs.
Feel free to send me a pull request! My code might be a little iffy but that's because I'm new to the rust ecosystem.
Licensed under the most permissive license, MIT.