myFavShrimp / turf

Macro based compile-time SCSS transpilation, CSS minification, and class name uniquification toolchain inspired by CSS modules.
MIT License
50 stars 2 forks source link

Could not obtain turf settings from the Cargo manifest #22

Closed emnul closed 1 month ago

emnul commented 1 month ago

I tried using turf in a leptos project, but my project fails to compile with the following error: error: Could not obtain turf settings from the Cargo manifest. Here's what my Cargo.toml file looks like:

[package]
name = "my-personal-website"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1"
http = { version = "1.0.0", optional = true }
leptos = { version = "0.6" }
leptos_meta = { version = "0.6" }
leptos_actix = { version = "0.6", optional = true }
leptos_router = { version = "0.6" }
wasm-bindgen = "=0.2.92"
turf = "0.9.0"

[features]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = [
   "dep:actix-files",
   "dep:actix-web",
   "dep:leptos_actix",
   "leptos/ssr",
   "leptos_meta/ssr",
   "leptos_router/ssr",
]

# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"

[package.metadata.leptos]
output-name = "my-personal-website"

site-root = "target/site"

site-pkg-dir = "pkg"

assets-dir = "assets"

reload-port = 3001

end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

env = "DEV"

bin-features = ["ssr"]

bin-default-features = false

lib-features = ["hydrate"]

lib-default-features = false

lib-profile-release = "wasm-release"

[package.metadata.turf]
minify = true
load_paths = ["styles"]

[package.metadata.turf.class_names]
template = "custom-<original_name>-<id>"

[package.metadata.turf.browser_targets]
chrome = [109]
firefox = [115]
android = [126]
ios_saf = [15.6]
edge = [124]
safari = [16, 6]
samsung = [24]
opera = [109]
ie = [11]

[package.metadata.turf.file_output]
global_css_file_path = "target/site/pkg/global.css"

[package.metadata.turf-dev]
debug = true
minify = false
load_paths = ["styles"]

[package.metadata.turf-dev.browser_targets]
chrome = [120]

[package.metadata.turf-dev.file_output]
global_css_file_path = "target/site/pkg/global.css"

[package.metadata.turf-dev.class_names]
template = "custom-<original_name>-<id>"

Everything seems to be configured fine, but I could be missing something.

In src/app.rs I have

turf::style_sheet!("styles/main.scss");

At the top of the file, but Rust refuses to compile it

myFavShrimp commented 1 month ago

Hey, thanks for reporting. Your issue helped me realize that turf wasn't providing enough information about the source of errors. I've created a new release that fixes this problem. By updating turf to 0.9.1, you'll get more detailed error messages, which will make it easier to resolve the issue

emnul commented 1 month ago

Those new error messages helped me figure out the issue and fix it. However, in the README.md file it explains that the browser version formats can be defined as:

major
Use a single integer to specify the major version number.
Example: 1 or [1] represent version 1.0.0

My project fails to build when I use the following configuration:

[package.metadata.turf.browser_targets]
chrome = [109]

but this works fine

[package.metadata.turf.browser_targets]
chrome = 109

Is this a bug with the settings parser?

myFavShrimp commented 1 month ago

This was indeed a bug in the settings parser. I resolved the issue in the latest release 0.9.2. Thank you very much for reporting the issue!