Using vanilla-extract with remix #178
-
Howdy y'all 👋🏻 First off, love the project. Thanks for all you do. I gave a shot at integrating vanilla-extract with remix last night, but hit a wall. This turns into a bit of a chicken/egg problem because the build creates a unique hash for each file, but you need to know that hash in order to include the file. This resolves itself with most files (the same way as with create-react-app), but not for dynamic files (not really dynamic, but the file's hash changes whenever the content changes) Here's a basic snippet: // app/utils/poc.css.ts
import { style } from "@vanilla-extract/css";
export const poc = style({
display: "flex",
});
// app/routes/index.tsx
...
import * as styles from "../utils/mvp.css";
export let links: LinksFunction = () => {
return [
{ rel: "stylesheet", href: "hmmm-how-do-i-get-this-hashed-url" },
];
};
export default function Index() {
return (
<div className={styles.poc}>
Hello World
</div>
);
} I believe this is a detail that needs to be sorted out on the Remix side of things, but wanted to poke at the idea to see if a different approach could make sense, especially given a server-side-rendering framework, maybe I should be building the css on-the-fly 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 11 replies
-
We chatted briefly with the Remix guys on twitter about this. We would love to support Remix but for now the Remix way of handling styles is incompatible with vanilla-extract. Mostly due to the styles having to return URLs, where as vanilla-extract returns references to your styles (like CSS modules). |
Beta Was this translation helpful? Give feedback.
-
There is any update on this? |
Beta Was this translation helpful? Give feedback.
-
Hey! Just wondering if we have any updates on this? Would really be a great help if we can use vanilla extract with remix Thanks! |
Beta Was this translation helpful? Give feedback.
-
I was hoping to use vanilla extract on my new remix project, bummer to see it is not yet supported. |
Beta Was this translation helpful? Give feedback.
-
remix team discussing about css modules here |
Beta Was this translation helpful? Give feedback.
-
For anyone still wondering if it can be possible to use vanilla-extract with remix it is possible. I wrote an example for the remix-esbuild-overide package. https://github.com/aiji42/remix-esbuild-override/tree/main/examples/vanilla-extract One thing to always take in mind is that the remix team is not officially supporting this kind of extensions and it can always break in a future release. |
Beta Was this translation helpful? Give feedback.
-
I made a prototype of compiling all vanilla-extract styles in a separate tsup process, then importing the built output into a Remix app. Obviously not the ideal, but I think it's a decent workaround at smaller scales until we get official support. https://github.com/markdalgleish/remix-vanilla-extract-prototype |
Beta Was this translation helpful? Give feedback.
-
Came here to see if this was possible and lo and behold a PR was just opened for it 😄 Excited to give it a try when it's available 👀 |
Beta Was this translation helpful? Give feedback.
We chatted briefly with the Remix guys on twitter about this. We would love to support Remix but for now the Remix way of handling styles is incompatible with vanilla-extract. Mostly due to the styles having to return URLs, where as vanilla-extract returns references to your styles (like CSS modules).