thgh / rollup-plugin-scss

Rollup and compile multiple .scss, .sass and .css imports
MIT License
134 stars 47 forks source link

@use rules must be written before any other rules. #70

Open jrkarlsson opened 3 years ago

jrkarlsson commented 3 years ago

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

ivannovazzi commented 3 years ago

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

thgh commented 3 years ago

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

onyxcodes commented 1 year ago

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?

thgh commented 1 year ago

PR welcome!

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

thgh commented 1 year ago

@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!

FrankGi1 commented 1 year ago

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!