Trunk has built-in support for tailwind with no further requirements. I generated a tailwind.css in my project root using npx tailwind -o ./tailwind.css, created a configuration file for tailwind, linked the tailwind.css to trunk, added some tailwind classes to an element, and my Firefox browser sadly does not display any of the applied tailwind classes. Here's my code:
$PRJ/src/main.rs:
use yew::prelude::*;
fn main() {
yew::Renderer::<App>::new().render();
}
#[function_component]
pub fn App() -> Html {
html! {
<div>
<h2 class={"text-3xl font-bold underline"}>{"Hello, World!"}</h2>
</div>
}
}
$PRJ/tailwind.config.js:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{rs,html}",
"./index.html"
],
theme: {
extend: {},
},
plugins: [],
}
$PRJ/index.html:
<!DOCTYPE html>
<html>
<head>
<!--Copy ./public dir into dist to be able to link relatively from the dist-dir-->
<link data-trunk rel="copy-dir" href="./public/" />
<link data-trunk rel="tailwind-css" href="./tailwind.css" />
<meta charset="utf-8" />
<title>Tauri + Yew App</title>
<link data-trunk rel="css" href="/public/main.css" />
</head>
<body></body>
</html>
trunk serve-output:
2023-11-11T21:15:34.574032Z INFO ๐ฆ starting build
2023-11-11T21:15:34.575004Z INFO spawning asset pipelines
2023-11-11T21:15:35.036450Z INFO copying & hashing css path="public/main.css"
2023-11-11T21:15:35.036504Z INFO copying directory path="public"
2023-11-11T21:15:35.036881Z INFO building frontend
2023-11-11T21:15:35.036963Z INFO finished copying directory path="public"
2023-11-11T21:15:35.037203Z INFO finished copying & hashing css path="public/main.css"
Compiling frontend v0.1.0 (/Users/star/Codespace/polyphony/client-web/crates/polyphony-wasm)
2023-11-11T21:15:35.383266Z INFO using system installed binary app=tailwindcss version=3.3.5
2023-11-11T21:15:35.383471Z INFO compiling tailwind css path="tailwind.css"
Rebuilding...
Done in 92ms.
2023-11-11T21:15:35.672986Z INFO finished compiling tailwind css path="tailwind.css"
Finished dev [unoptimized + debuginfo] target(s) in 1.07s
2023-11-11T21:15:36.147527Z INFO fetching cargo artifacts
2023-11-11T21:15:36.260786Z INFO processing WASM for frontend
2023-11-11T21:15:36.281116Z INFO using system installed binary app=wasm-bindgen version=0.2.87
2023-11-11T21:15:36.281189Z INFO calling wasm-bindgen for frontend
2023-11-11T21:15:36.383159Z INFO copying generated wasm-bindgen artifacts
2023-11-11T21:15:36.387226Z INFO applying new distribution
2023-11-11T21:15:36.388539Z INFO โ
success
2023-11-11T21:15:36.390534Z INFO ๐ก serving static assets at -> /
2023-11-11T21:15:36.390630Z INFO ๐ก server listening at http://127.0.0.1:8080
Browser view is attached as an image. What am I doing wrong?