Skip to content

CSS Imports Getting Removed from Build Output #1784

@thomas-j-moffett

Description

@thomas-j-moffett

I am interested in helping provide a fix!

Yes

Which generators are impacted?

  • All
  • Angular
  • HTML
  • Preact
  • Qwik
  • React
  • React-Native
  • Solid
  • Stencil
  • Svelte
  • Vue
  • Web components

Reproduction case

https://mitosis.builder.io/playground/?code=JYWwDg9gTgLgBAbzgVwM4FMDKMCGN1wC%2BcAZlBCHAEQACARssADYAm6UAdMBAPQjAwIqYKioBuAFChIsOAHJ8qGBwDGqVHMkT0ADxnw2JHMibwSyAHYqY3C3ACyATwDCFSBfQWYACjDkwqACUiBJwcCoQFkpwANoWOCDoADRwGDAAcgnoALpwALwoGNh46N5U2OgAbuhUgVphUOgwyFB23qFhcAA8LMCVAHwdnd3AFmDIMEPD4ep5CAhT0%2BEQTNAAXNSNLFRJi52EhHthlThMyOhz8YmHS2GRzgAWOBYA5hcI3lWeMMF5%2FalNTKJT7VLwcXBQN7KE5ndCBG7THiDJYACXQTFWAEI4ABJcLPOBQSxweI2apMRxwUZwABK6Bw1hSADVzilMOT8CkAIoAd2AAGsUs8WHAQM9KSBoAQyFkedB%2BahMVMujxegMOnUJIQgA%3D%3D%3D

Expected Behaviour

I expect the CSS imports to stay in the file.

I'm not expecting anything fancy for Mitosis to handle CSS, but I needed the imports to remain in the file. Your docs show that is supposed to be a possibility: https://mitosis.builder.io/docs/components/#import-css-file

I thought that it was supposed to work that way, and weirdly enough, the Playground does show it working that way, but I was able to reproduce the issue following your Quickstart docs (see my additional info section).

I only tried this with React. I have not tried other frameworks/libraries for output.

Actual Behaviour

CSS imports are getting removed from the output.

Additional Information

I thought this was maybe just a problem in my project, but I created a completely separate test project from scratch using the Quickstart in your docs, and I was able to reproduce the issue. I tried to keep everything at defaults and only add my CSS import.

npm create @builder.io/mitosis@latest

> npx
> create-mitosis

┌  Welcome to Mitosis! Let's get started.
│
◇  What is your Mitosis project name?
│  my-project
│
◇  Select your desired outputs
│  react
│
◇   ────────────────────────────╮
│                               │
│  Generating your template...  │
│                               │
├───────────────────────────────╯
│
◇   ────────────────────╮
│                       │
│  Template generated!  │
│                       │
├───────────────────────╯
│
◇  Install dependencies?
│  Yes
│
◇   ─────────────────────────────────────────────────╮
│                                                    │
│  Installing dependencies...this may take a while!  │
│                                                    │
├────────────────────────────────────────────────────╯

Then, in the my-project/library/src/autocomplete/autocomplete.lite.tsx file I added a import './test.css'; line:

import { For, onUpdate, Show, useStore } from '@builder.io/mitosis';
import './test.css';

export type Props = {

...

Then, the output file my-project/library/packages/react/src/autocomplete/autocomplete.tsx, had this content at the top (and test.css import is nowhere in the file):

"use client";
import * as React from "react";
import { useState, useEffect } from "react";

export type Props = {
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions