Closed CarlosNZ closed 1 year ago
There's no bug, this is the intended behavior.
While we're getting closer, there's still no standardized way to reference CSS files from within JS, especially in ecosystems like NPM. As such, we strip out references to CSS because how you consume it in different environments (if the environment can at all) varies wildly.
Your consumers will need to "import" the CSS separately according to their environment.
Okay, thanks for the quick response, @rschristian, and the issue link is an interesting read.
Might have to look into some alternative approaches.
I've only vaguely tracked it, but I believe Import assertions/attributes are the eventual solution here, but they did just get demoted back to stage 2 a few months ago, so it'll probably be a fair while yet.
Going to close this out as there's nothing actionable here for us. Certainly feel free to reply if you have any other issues.
I have a "style.css" in the same folder as my entry point "index.ts". I have
import './style.css'
in my project and it works just fine in development.However, when running
microbundle
, all reference to the css file is stripped from the compiled output. The css file is copied to the output folder. (as "index.css") though.I've temporarily set
--compress false
in my microbundle command so I can read the output js easier, and there is no reference whatsoever to the CSS import any more, and so the built package doesn't have any styles. If I manually addrequire('./index.css')
to the compiledindex.js
, it works.So what am I doing wrong, or is this a bug? Is it a Typescript thing? I've tried various settings for
--css-modules
, with no improvement. 🤷♂️Any help appreciated. :)