rollup-plugin-scss icon indicating copy to clipboard operation
rollup-plugin-scss copied to clipboard

@use rules must be written before any other rules.

Open jrkarlsson opened this issue 4 years ago • 6 comments

It would nice to be able to use sass/dartsass and the at-rules, especially the @use since @import has been deprecated(https://sass-lang.com/documentation/at-rules/import). However doing so will most likely yield a compilation error: "@use rules must be written before any other rules."

I looked a bit at the code and it seems like the plugin is concatenating all the scss partials and then compiling it to css. By doing so @use rules will end up in the middle of the concatenated string which yields the error.

I created a small repo to reproduce the issue: https://github.com/jrkarlsson/rollup-plugin-scss-issue

jrkarlsson avatar Mar 11 '21 22:03 jrkarlsson

Any update on this? This is preventing my library to build.

ivannovazzi avatar May 31 '21 12:05 ivannovazzi

I'm not planning to work on this issue, but PRs welcome!

thgh avatar May 31 '21 13:05 thgh

I've made some edits to parse correctly @use rules: https://github.com/onyxcodes/rollup-plugin-scss/tree/use-rules.

Had to add a config basePath to be able to resolve paths when using ~. But by default it will use the root directory of the rollup configuration.

@thgh what do you think?

onyxcodes avatar Oct 26 '22 22:10 onyxcodes

PR welcome!

Let's make a v4 with Rollup 3 support, emitFile and this

thgh avatar Oct 27 '22 10:10 thgh

@onyxcodes Can you explain me what you mean with the additional features (Rollup 3 compatibility and emitFile).. in case I may help with those too.

Hi Onyx,

You can make a pull request from this page. That will create an entry in the list of pull requests. From there, I and other people can easily review your changes. When everything looks good, we will merge the changes in the v3 branch.

There is also a v4 branch recently using "emitFile" from Rollup which allows for smarter filenames of assets like css files.

Looking forward to your PR!

thgh avatar Dec 21 '22 16:12 thgh

Hey, sorry came late to the party, was the PR created? Is there any fix for this issue, I am facing the same and wonder if there is a work around?

Thanks!

FrankGi1 avatar Jun 21 '23 11:06 FrankGi1