vite icon indicating copy to clipboard operation
vite copied to clipboard

Use the modern SASS compiler API

Open KaelWD opened this issue 2 years ago • 7 comments

Clear and concise description of the problem

sass-loader v12.5 added an option to switch to sass.compileAsync instead of the old sass.render, allowing for use of the new Importer interface which supports @use

https://github.com/webpack-contrib/sass-loader#api

Suggested solution

Either switch to compileAsync (breaking change though) or add a similar option as the webpack plugin for people who need the new API.

Alternative

No response

Additional context

Related: #3180

Validations

KaelWD avatar Feb 28 '22 08:02 KaelWD

I think we would be using sass.compileString instead since sass.compile reads from the filesystem. I looked into the types, and it looks like the options for compileString extends from render, so maybe it's not a breaking change if we alternate between compileString and render depending on which API is available.

Related: https://github.com/vitejs/vite/issues/6734.

bluwy avatar Feb 28 '22 17:02 bluwy

FYI, I made a simple attempt to support SASS modern API #7170

ygj6 avatar Mar 04 '22 06:03 ygj6

Hi! What is the status on this issue?

pvanagtmaal avatar Jul 18 '22 08:07 pvanagtmaal

@ygj @KaelWD @bluwy @sapphi-red You might already have seen this, but https://github.com/sass/sass/issues/3247 was recently resolved and it seems like the speed improvements could be significant. Just as a friendly FYI 😄

danieka avatar Jan 26 '24 14:01 danieka

@sapphi-red

Wanted to ref a non-breaking change for this ( #14689 ).

If we allow both legacy and modern modes with a super-simple flag in the config, then it should be a point fix which would be great to get earlier, since it is both a performance and a functionality issue.

john-easci avatar May 06 '24 15:05 john-easci

Definitely, I forgot why I put the label.

sapphi-red avatar May 07 '24 09:05 sapphi-red

If I understand correctly, the blockers on upstream are all gone and just needs someone to implement it.

sapphi-red avatar May 07 '24 09:05 sapphi-red

If I understand correctly, the blockers on upstream are all gone and just needs someone to implement it.

Yes, and in some cases, this should be a fix instead of improvements, because the current api is already deprecated, and some new features could not be configured.

For example, https://github.com/sass/dart-sass/issues/2276#issuecomment-2226843129

Mister-Hope avatar Jul 13 '24 13:07 Mister-Hope