-
Notifications
You must be signed in to change notification settings - Fork 363
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
Inline CSS file as string - CJS bundle simply converts this to void 0
#744
Comments
Strange that this would vary between CJS and the other formats. I had thought that Microbundle's CSS handling would return a URL, not the CSS file as a string. Do you have configuration set up to alter that? |
Sorry, completely forgot, using TS and therefore have a declaration file that looks like this:
|
Hi @developit! Is there a way to force importing a file content as a string? import text from 'raw-loader!./css/styles.css'
// or
import text from './css/styles.css?as=text' |
@omgovich Microbundle doesn't have loaders or anything like that. The only way to hack it in would be a Babel plugin that transforms the import inline into a string. |
Thanks for the advice! |
Ah interesting. I'm betting we are actually just failing to do CJS<->ESM default interop then and Terser is folding away the missing property access. |
Found the bug. |
* Add --css inline option Fixes #744 * Add CLI option * Add docs for --css and update --css-modules docs * Create rude-keys-eat.md * update snapshot
Hi @developit! Hope you're doing well. I recently published an article where mentioned your invaluable support and results we achieved using the new Microbundle: |
Bit of a weird use case, but I need to inline a CSS file as a string within a bundle.
I can do this just fine with UMD, ES Module, and Modern outputs, but where they contain a string representation of the CSS file, the CJS output just has
void 0
in its place. Bug, or is this a limitation of the CJS output in some way?While
console.log()
is certainly not the "real" use case, it acts the same as the real use case and is simpler to display with.This is also with the
--css-modules
flag having been set tofalse
.The text was updated successfully, but these errors were encountered: