Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styles don't get updated #3

Closed
xYouLL opened this issue Jul 19, 2023 · 5 comments
Closed

Styles don't get updated #3

xYouLL opened this issue Jul 19, 2023 · 5 comments

Comments

@xYouLL
Copy link

xYouLL commented Jul 19, 2023

Hello, I'm currently trying turf with Leptos.
I'm facing some issues while on trunk serve --open, everytime I try to edit an existing style it doesn't get updated even if I stop the ongoing serve and start again and also if I try to delete the cache by CTRL + F5.
It just gets updated randomly, without any criteria from what I see.

Turf version: 0.4.0
Leptos version: 0.4.4 (features: csr, nightly)
Leptos router version 0.4.4 (features: csr)

@xYouLL xYouLL changed the title CSS Cache Styles don't get updated Jul 19, 2023
@myFavShrimp
Copy link
Owner

Hey, thanks for reporting the issue. I have also noticed this problem lately and came up with a solution.

You need to create a build.rs build script file in your project root (right next to your src directory). In the build.rs you put the following content:

fn main() {
    // Tell Cargo that if the given file changes, to rerun this build script.
    println!("cargo:rerun-if-changed=src/**/*.scss");
}

src is the directory containing your SCSS files. You may need to change this path according to your project setup.

Sadly, there seems to be no other way currently as this is a limitation of Rust itself. I'm still in the process of thinking about a proper way to handle this but I will document this build script solution in turf's README and example projects.

Thanks again for posting the issue. Please let me know if this solved the problem for you 🙂

@wrapperup
Copy link

wrapperup commented Jul 25, 2023

Sadly, there seems to be no other way currently as this is a limitation of Rust itself. I'm still in the process of thinking about a proper way to handle this but I will document this build script solution in turf's README and example projects.

Currently, the tracked path API is a thing, but nightly only. A trick Askama uses to track files right in the macro in stable is by using include_bytes!, but not actually using it. See here

@myFavShrimp
Copy link
Owner

A trick Askama uses to track files right in the macro in stable is by using include_bytes!, but not actually using it.

Thanks for pointing out this trick. Using include_bytes is clever. I personally like to have more consistent behavior so I'd favor a solution that makes tracking files included using the load_paths setting possible too. I will experiment a little with it (e.g. for using it for the load_paths files as well).

@myFavShrimp
Copy link
Owner

Good news! I implemented a first draft of the include_bytes file tracking and it works for load_paths files as well. I have to make some changes to how the file paths are handled by turf before this can land on main as the include_bytes macro assumes paths to be relative to the current file's directory while everything else in turf needs them to be relative to Cargo's current working directory.

@myFavShrimp
Copy link
Owner

The necessary changes have been made and are included in the latest 0.6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants