remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
28.45k stars 2.39k forks source link

Vite: `.css?url` import used via `loader` not applying styles in production #8786

Closed manzano78 closed 4 months ago

manzano78 commented 4 months ago

Reproduction

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @remix-run/dev: 2.7.0-pre.0 => 2.7.0-pre.0 
    @remix-run/node: 2.7.0-pre.0 => 2.7.0-pre.0 
    @remix-run/react: 2.7.0-pre.0 => 2.7.0-pre.0 
    @remix-run/serve: 2.7.0-pre.0 => 2.7.0-pre.0 
    vite: 5.1.3 => 5.1.3

Used Package Manager

npm

Expected Behavior

The styles of ~/styles.css?url in root.tsx should be applied

Actual Behavior

The styles of ~/styles.css are not applied because the browser can't reach the file (HTTP 404). The reason is the production build didn't copy the file to client public assets. It works in development though. It also works if I use another extension than .css. My use case is to manage dynamic stylesheets based on the domain for multi-branding without sending every theme information to the browser. This works in the current Remix bundler.

Note: the vite version I use contains the fix of the .css?url issue.

github-actions[bot] commented 4 months ago

🤖 Hello there,

We just published version 2.7.0-pre.2 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

markdalgleish commented 4 months ago

@manzano78 Thanks for raising this issue, and thanks for the repro! I've checked 2.7.0-pre.2 against your StackBlitz and everything seems to be working.

github-actions[bot] commented 4 months ago

🤖 Hello there,

We just published version 2.7.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!