vanilla-extract icon indicating copy to clipboard operation
vanilla-extract copied to clipboard

[Remix/Vite] Vanilla generated css files doesn't get injected into html after build

Open vincent-thomas opened this issue 1 year ago • 5 comments

Describe the bug

Vanilla css styles do get injected into html in dev mode, but in production they don't get injected. They do generate in the build/client/assets directory but are not 'used'.

I use bun as package manager

NOTE: To have exactly my setup use my flake.nix with the nix package manager. not a must at all but its nice.

Head tag in devmode

<head>
   ...

  <style>
  /* /app/root.css.ts.vanilla.css */
  body {
    background-color: red;
  }
  <link .... />
  <link .... />
  <link .... />
</head>

Head tag in prod

<head>
   ....


   <!-- No vanilla css files here --> 

  <link .... />
  <link .... />
  <link .... />
</head>

Reproduction

https://github.com/vincent-thomas/remix-vanilla-extract-css-repro

System Info

System:
    OS: Linux 6.6 NixOS 24.11 (Vicuna) 24.11 (Vicuna)
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 22.59 GB / 31.25 GB
    Container: Yes
    Shell: 5.9 - /run/current-system/sw/bin/zsh
  Binaries:
    Node: 22.8.0 - /nix/store/xsrv93rg8vi05k9ig6v9mcvcyn01n6n2-nodejs-22.8.0/bin/node
    npm: 10.8.2 - /nix/store/xsrv93rg8vi05k9ig6v9mcvcyn01n6n2-nodejs-22.8.0/bin/npm
    bun: 1.1.29 - /nix/store/mqzlk40bnhx54by2m4lyyc02syippzad-bun-1.1.29/bin/bun

Used Package Manager

npm

Logs

No response

Validations

vincent-thomas avatar Sep 29 '24 20:09 vincent-thomas

Thanks for raising an issue. I've reproduced it locally and can confirm that the styles are missing. Specifically, it seem like remix is the side-effect import of the VE file, but it doesn't strip the tailwind one. If I export a style and use it within the app, all styles are present in a stylesheet.

I tested this out in a plain vite app and it is not an issue there, so it's specific to remix.

askoufis avatar Oct 01 '24 04:10 askoufis

Okay i'll open an issue on remix instead

vincent-thomas avatar Oct 01 '24 19:10 vincent-thomas

@vincent-thomas Sorry if my response sounded dismissive. I'm happy to keep this issue open at least to provide visibility on the VE side, but an issue in Remix would certainly be useful as well.

askoufis avatar Oct 02 '24 05:10 askoufis

No problem, i totally understand that issues need to be closed and developer time should be focused on real vanilla extract bugs. Maybe this issue could be referenced under this page (https://vanilla-extract.style/documentation/integrations/remix)?

NOTE: I can open a pull request regarding this.

Btw I really like this library, an issue has been opened remix.

vincent-thomas avatar Oct 02 '24 13:10 vincent-thomas

Tracked in remix https://github.com/remix-run/remix/issues/10045

askoufis avatar Oct 03 '24 12:10 askoufis

Closing since the upstream has been closed as not planned.

askoufis avatar Aug 19 '25 09:08 askoufis