Is there a way to use Dart Sass command line version with web pack?

579 views Asked by At

From the dart-sass documentation we see that the dart-sass has a command-line version and is more performant.

I want to know if we can somehow use that command-line version with the existing webpack set up to speed up our build-time performance.

I can install dart libraries in the build machine. But is there any webpack plugin which can leverage that and use the machine dependencies to build sass rather than dart-sass npm?

1

There are 1 answers

0
msmith On

It seems as though the dart-sass team is working to support this case (see this issue). But the work isn't finished.

But is there any webpack plugin which can leverage that and use the machine dependencies to build sass rather than dart-sass npm?

Not that I can find. However, it would be possible to create your own loader which uses the dart executable (the source for sass-loader is a good point of reference, and not very complicated). Since the dart cli takes options to read from stdin (sass --stdin), you should be able to pipe to the cli and pass back the output.

There might be other ways to accomplish your aim with a webpack extension, but using a loader seems the most straightforward in my view.

Is this faster than using the js api that sass-loader uses? Well, according to the benchmarks, the advantage of the executable varies between 1.7 and 4.1 times faster (excluding the simplest case in which the executable runs 24 times faster, but is still sub-second execution for all cases). But there will be overhead for process generation, so you would have to measure to see what is faster in your case.