Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
242 stars 43 forks source link

Inject var instead of const? #145

Closed mindplay-dk closed 3 years ago

mindplay-dk commented 3 years ago

I have the plugin configured like this:

        styles({
            // https://anidetrix.github.io/rollup-plugin-styles/interfaces/_index_d_.options.html
            mode: ["inject", () => ""], // NOTE: using an empty closure to bypass code-generation in `styles` and just inline the CSS source
            minimize: true,
        }),

(Note that I'm using a custom callback with inject here to bypass the built-in code generation - I just want the CSS as a string, I have my own code for injecting it.)

Now the input:

import css from "./widget.css";

Correctly gets converted to:

const css = "....";

And so far so good.

But then after your plugin, I have the Babel plugin, which is configured to convert const into var.

Somehow that doesn't work?

Other const in my code get converted to var - but the resulting const from this plugin does not.

Changing the order of plugins doesn't seem to change anything.

Is there any way to configure the plugin itself to emit var instead of const?

(Doesn't the plugin order in rollup define the order of processing? or what am I not understanding here?)

Anidetrix commented 3 years ago

Hello @mindplay-dk,

I believe this has been fixed by @tjenkinson in his Pull Request, but it has not been released yet. I did not have a lot on time to work on this plugin lately, so the progress is a bit slow, but this will be included in the next release.

mindplay-dk commented 3 years ago

Looks like yes.

If you want to publish a pre-release, I'd be happy to test. 🙂

Anidetrix commented 3 years ago

Should be fixed for a while, closing