I have looked up how to setup Tailwind with Remix ( https://tailwindcss.com/docs/guides/remix) and that's fine. And I saw there is a way to use Remix in SPA mode ( https://remix.run/docs/en/main/future/spa-mode ). But setting up Tailwind assumes you're using Remix with SSR mode it looks like, none of the CSS is working or being included. It took a long time but i got it figured out and figured I'd share.
- Setup Remix in SPA mode https://remix.run/docs/en/main/future/spa-mode
- Follow https://tailwindcss.com/docs/guides/vite (NOT the Remix guide yet)
- Modify the
/app/root.tsxto import Tailwind now ( Step 5 of https://tailwindcss.com/docs/guides/remix ) but include a "?url" at the end like this:
import type { LinksFunction } from "@remix-run/node";
import stylesheet from "~/tailwind.css?url";
export const links: LinksFunction = () => [
{ rel: "stylesheet", href: stylesheet },
];
- Create a
/postcss.config.jsat the root wherepackage.jsonis, containing the following:
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
- Run
npm run dev - Profit.
Thanks to ( #1207010713995055214 message ) for helping me figure out this puzzle!