diff --git a/.changeset/css-bundling.md b/.changeset/css-bundling.md new file mode 100644 index 00000000000..b918ae92e1e --- /dev/null +++ b/.changeset/css-bundling.md @@ -0,0 +1,118 @@ +--- +"@remix-run/dev": minor +"@remix-run/react": minor +"@remix-run/server-runtime": minor +"@remix-run/testing": minor +--- + +Enable support for [CSS Modules](https://github.com/css-modules/css-modules), [Vanilla Extract](http://vanilla-extract.style) and CSS side-effect imports + +These CSS bundling features were previously only available via `future.unstable_cssModules`, `future.unstable_vanillaExtract` and `future.unstable_cssSideEffectImports` options in `remix.config.js`, but they have now been stabilized. + +**CSS Bundle Setup** + +In order to use these features, you first need to set up CSS bundling in your project. First install the `@remix-run/css-bundle` package. + +```sh +npm i @remix-run/css-bundle +``` + +Then return the exported `cssBundleHref` as a stylesheet link descriptor from the `links` function at the root of your app. + +```tsx +import type { LinksFunction } from "@remix-run/node"; // or cloudflare/deno +import { cssBundleHref } from "@remix-run/css-bundle"; + +export const links: LinksFunction = () => { + return [ + ...(cssBundleHref + ? [{ rel: "stylesheet", href: cssBundleHref }] + : []), + // ... + ]; +}; +``` + +**CSS Modules** + +To use [CSS Modules](https://github.com/css-modules/css-modules), you can opt in via the `.module.css` file name convention. For example: + +```css +.root { + border: solid 1px; + background: white; + color: #454545; +} +``` + +```tsx +import styles from "./styles.module.css"; + +export const Button = React.forwardRef( + ({ children, ...props }, ref) => { + return ( +