Astro/Vite: How to dynamically import CSS from an NPM package

129 views Asked by At

I would like to dynamically import CSS from an NPM package in an Astro layout:

---
const { variant } = Astro.props;
import(`@pkg/lib/css/${variant}.css`);
---

But this gives me an error:

Unknown file extension ".css"

Is there a way to achieve this?

0

There are 0 answers