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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite: Build fails to serve css-modules files properly #7941

Closed
1 task done
mikkpokk opened this issue Nov 8, 2023 · 1 comment
Closed
1 task done

Vite: Build fails to serve css-modules files properly #7941

mikkpokk opened this issue Nov 8, 2023 · 1 comment

Comments

@mikkpokk
Copy link

mikkpokk commented Nov 8, 2023

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Create a clean project

npx create-remix@latest --template remix-run/remix/templates/unstable-vite

Create a Test component with css-modules:

app/component/Test/index.tsx

import style from './Test.module.css'

const Test = () => {
    return (
        <div className={style.Test}>
            Test style
        </div>
    )
}

export default Test

app/component/Test/Test.module.css

.Test {
    background: #ff9100;
    color: #fff;
}

Create new route file

app/routes/test.tsx

import type { MetaFunction } from "@remix-run/node";
import Test from '~/component/Test'
import {Link} from '@remix-run/react'

export const meta: MetaFunction = () => {
    return [
        { title: "Test page" },
    ];
};

export default function Index() {
    return (
        <div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
            <h1>Welcome to Remix</h1>
            <ul>
                <li>
                    <Link to={'/'}>
                        Index
                    </Link>
                </li>
            </ul>
            <Test/>
        </div>
    );
}

Use Test component on index route & apply Link to /test route

_app/routes/index.tsx

import type { MetaFunction } from "@remix-run/node";
import Test from '~/component/Test'
import {Link} from '@remix-run/react'

export const meta: MetaFunction = () => {
  return [
    { title: "New Remix App" },
    { name: "description", content: "Welcome to Remix!" },
  ];
};

export default function Index() {
  return (
    <div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
      <h1>Welcome to Remix</h1>
      <ul>
        <li>
          <Link to={'/test'}>
            Test
          </Link>
        </li>
        <li>
          <a
            target="_blank"
            href="https://remix.run/tutorials/blog"
            rel="noreferrer"
          >
            15m Quickstart Blog Tutorial
          </a>
        </li>
        <li>
          <a
            target="_blank"
            href="https://remix.run/tutorials/jokes"
            rel="noreferrer"
          >
            Deep Dive Jokes App Tutorial
          </a>
        </li>
        <li>
          <a target="_blank" href="https://remix.run/docs" rel="noreferrer">
            Remix Docs
          </a>
        </li>
      </ul>
      <Test/>
    </div>
  );
}

Run npm run build && npm run start

Expected Behavior

Test component should have orange background and white font color on routes / and /test. There should be have 1 css file on inside <head> tag.

Actual Behavior

Test component don't have styles, component have it's class on DOM but css file missing from <head> tag.

@markdalgleish
Copy link
Member

markdalgleish commented Nov 9, 2023

Thanks for raising this issue!

Fixed by #7952. This will be available in the next nightly release if you want to try it before it goes out.

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

No branches or pull requests

3 participants