QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.82k stars 1.3k forks source link

[BUG] CSS styles from `global.css` not applied in any starter #681

Closed wtho closed 2 years ago

wtho commented 2 years ago

Qwik Version

0.0.30

Operating System (or Browser)

Linux 5.18.6, Chromium 103.0.5060.53

Node Version (if applicable)

18.3.0

Which component is affected?

Starters / CLI

Expected Behaviour

The global styles should be applied, in both, DEV and SSR builds

Actual Behaviour

The styles are never added to the websites. They only seem to be applied when loaded e. g. via useStyles$.

Additional Information

A workaround seems to add the styles to a component$ using useStyles$, which is also how it currently works in the packages/docs project:

import styles from '../../global.css';

import { component$, useStyles$ } from '@builder.io/qwik'

export const App = component$(() => {
  useStyles$(styles)
  // [...]
})

Related (were closed although not solved, this issue is now the follow-up):

  1. https://github.com/BuilderIO/qwik/issues/583
  2. https://github.com/BuilderIO/qwik/issues/626

I hope this time we will be able to fix it before closing it prematurely!

Reproduction

  1. npm init qwik@latest
  2. Project Name -> qwik-app
  3. Select a Starter -> Starter
  4. Select a Server -> Setup later
  5. Features -> Prettier
  6. cd qwik-app
  7. npm install
  8. npm start
  9. Add html { background-color: red } to global.css
  10. Open localhost:3000 - no red background visible, rule not applied :sad
wtho commented 2 years ago

I think it works now if the CSS module is included in the entry module, in my case entry.ssr.tsx or entry.dev.tsx. If it is included in root.tsx or app.tsx, it does not work.

manucorporat commented 2 years ago

fixed by https://github.com/BuilderIO/qwik/commit/1dcf329a1b7654e56642e7bac26e4610073ebe12