You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrate Remix with [vanilla-extract.](https://vanilla-extract.style)
3
+
Integrate Remix with [Vanilla Extract.](https://vanilla-extract.style)
4
4
5
5
## Preview
6
6
@@ -10,33 +10,19 @@ Open this example on [CodeSandbox](https://codesandbox.com):
10
10
11
11
## Example
12
12
13
-
This example shows how to use vanilla-extract in Remix. Vanilla-extract is a zero-runtime CSS-in-TypeScript library that converts `.css.ts` files into static CSS at build time, providing first-class support for local-scoping of classes, variables, themes and more.
14
-
15
-
## Architecture and Tradeoffs
16
-
17
-
- A separate [tsup](https://github.com/egoist/tsup) process is needed to generate CSS, JavaScript and type definitions, whereas vanilla-extract is typically hooked up to your bundler. Effectively we're treating vanilla-extract more like a traditional CSS preprocessor like [Sass](https://sass-lang.com) or [Less.](https://lesscss.org)
18
-
- All styles from `.css.ts` files need to be manually re-exported from `/.styles/index.ts` which is then compiled into `/app/styles` for the Remix app to consume. You can think of it as maintaining a style manifest file. Conceptually this is the same as writing an `index.scss` file in Sass, except that JavaScript code and type definitions are generated in addition to CSS.
19
-
- All styles are built into `/app/styles/index.css` which your Remix app needs to include via a `links` function.
20
-
- Remix app code always needs to import styles from `~/styles`, even if a `.css.ts` file is in the same directory as the Remix code that imports it. If you don't do this, your vanilla-extract styles won't be compiled properly as they will go directly through the Remix compiler.
21
-
- You can keep the file size down using [Sprinkles](https://vanilla-extract.style/documentation/packages/sprinkles) which generates compression-friendly atomic CSS. You can then access these classes at runtime via the type-safe `sprinkles` function.
22
-
- To reduce boilerplate in your React code, Sprinkles can be wired up to a `Box` component as demonstrated in this project, allowing you to access atomic styles via props.
13
+
This example shows how to use the built-in Vanilla Extract support in Remix. Vanilla Extract is a zero-runtime CSS-in-TypeScript library that converts `.css.ts` files into static CSS at build time, providing first-class support for local-scoping of classes, variables, themes and more.
23
14
24
15
## Relevant Files
25
16
26
-
-[tsup.config.js](./tsup.config.js) where tsup is configured with the vanilla-extract esbuild plugin.
27
-
-[package.json](./package.json) where tsup is hooked up to the `dev` and `build` scripts using [npm-run-all.](http://npmjs.com/package/npm-run-all)
28
-
-[.styles/index.ts](./.styles/index.ts) where everything generated by vanilla-extract is re-exported for the Remix app to consume.
29
-
-[.styles/global.css.ts](./.styles/global.css.ts) where global styles are defined.
30
-
-[.styles/sprinkles.css.ts](./.styles/sprinkles.css.ts) where utility classes are configured using Sprinkles.
31
-
-[app/root.tsx](./app/root.tsx) where the generated CSS file is imported into the Remix app.
17
+
-[remix.config.js](./remix.config.js) where the `future.unstable_vanillaExtract` flag is enabled.
18
+
-[app/root.tsx](./app/root.tsx) where the CSS bundle is imported into the Remix app, provided by the `@remix-run/css-bundle` package.
19
+
-[app/global.css.ts](./.styles/global.css.ts) where global styles are defined.
20
+
-[app/components/Box/sprinkles.css.ts](./.styles/sprinkles.css.ts) where utility classes are configured using Sprinkles.
32
21
-[app/components/Box/Box.ts](./app/components/Box/Box.ts) where the utility classes generated by Sprinkles are hooked up to a primitive `Box` component.
33
-
-[app/components/Text/Text.tsx](./app/components/Text/Text.tsx) where you can see an example of component-level styles being imported from `~/styles`.
22
+
-[app/components/Text/Text.tsx](./app/components/Text/Text.tsx) where you can see an example of component-level styles being consumed.
34
23
-[app/components/Text/Text.css.ts](./app/components/Text/Text.css.ts) where you can see an example of component-level styles being defined.
35
-
-[.eslintrc](.eslintrc) where everything in the generated `/app/styles` directory is added to ESLint's `ignorePatterns`.
36
-
-[.gitignore](.gitignore) where the generated `/app/styles` directory is added to the ignore list.
0 commit comments