Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing sonner styles in Remix + Vite application #386

Open
edbella opened this issue Mar 26, 2024 · 1 comment
Open

Missing sonner styles in Remix + Vite application #386

edbella opened this issue Mar 26, 2024 · 1 comment

Comments

@edbella
Copy link

edbella commented Mar 26, 2024

Describe the feature / bug 馃摑:

I'm running a Remix application with the Vite bundler approach. When I trigger a toast, I see the toast content appended to the DOM but it is not displayed on the screen. After taking a deeper look, I realised that the style.css in the Toaster component is not loaded into the page.

I guess this has to do with the requirement of using url imports for css side effects e.g styles.css?url as required by the bundler.

In the meantime I have created a css file containing the values contained in styles.css and imported that manually in my project and it works.

Steps to reproduce the bug 馃攣:

  1. npx create-remix
  2. npm i sonner
  3. Trigger toast after following the setup as described in the documentation
@dtmzr
Copy link

dtmzr commented Apr 7, 2024

@edbella I encountered the same in my setup, however only dev is affected. The production build works fine.

For everyone new to remix, you can fix it for your dev setup like this in root.tsx:

import sonnerStyles from "~/components/ui/sonner.css?url"; // copy this file form this repo

export const links: LinksFunction = () => [
    // your other links
    ...(process.env.NODE_ENV === "development"
    ? [{ rel: "stylesheet", href: sonnerStyles }]
    : []),
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants