The idea is that the Babel plugin should be able to generate import statements that import CSS as data URLs. After this, bundlers should be able to generate CSS bundles to include this CSS and a PostCSS/LightningCSS plugin can post-process the CSS file after the fact.
Challenge
I am unable to figure out a valid format for CSS data URL that can be put into a JS import statement.
I tried to come up with the simplest possible example of trying to inject body{background:pink} and tried the following import statements:
Resolving #297
Idea
The idea is that the Babel plugin should be able to generate import statements that import CSS as data URLs. After this, bundlers should be able to generate CSS bundles to include this CSS and a PostCSS/LightningCSS plugin can post-process the CSS file after the fact.
Challenge
I am unable to figure out a valid format for CSS data URL that can be put into a JS import statement.
I tried to come up with the simplest possible example of trying to inject
body{background:pink}
and tried the following import statements:I wasn't able to get any of them work in a fresh NextJS example. Webpack did not understand any of these imports.
I tried the same in Vite with similar results.
Is there a particular way to make bundlers bundle CSS provided this way?
Is this approach even feasible? I'm putting up this PR in case someone has further insight here.
We are independently working on a CLI to work around bundlers entirely in the meantime.