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

Use dart sass only

Open TeoTN opened this issue 3 years ago • 4 comments

Hey! I was wondering, cause the documentation doesn't mention it, if it's possible to use only dart-sass and not the node-sass? If so, how?

TeoTN avatar Sep 21 '20 11:09 TeoTN

I tried before, just replace node-sass with sass

shalldie avatar Oct 16 '20 07:10 shalldie

the problem with this plugin is that you can't configure explicitely which sass loader you want to use. Since other projects might have node-sass as a dependency, you're at the mercy of hoping that node-sass isn't installed. Based on this snippet in this projects' code you can see that it's just selecting node-sass as the preferred sass loader if it's found. So be careful saying that 'it just works', because it will break the moment you install a package that's incompatible with this logic: https://github.com/egoist/rollup-plugin-postcss/blob/92b274431e2433746d39f1e37877dfda7cf1230e/src/sass-loader.js#L22-L29

https://github.com/egoist/rollup-plugin-postcss/blob/92b274431e2433746d39f1e37877dfda7cf1230e/src/sass-loader.js#L96-L103

vincentbriglia avatar Nov 11 '20 09:11 vincentbriglia

Yep, this is a serious and pretty dangerous limitation, because it's not clear from the developer's perspective what runtime will be actually used for SASS processing.

I guess the first thing that should be done is switching from using node-sass to using sass by default, because sass (Dart SASS) is a reference implementation, which is probably more preferred. But it's not a final solution of course.

It should be possible not only to select a runtime by it's name, but also by passing a module directly or a full path of the module to the plugin, i.e.: sassRuntime: require('sass') or sassRuntime: require.resolve('sass'), because in complex projects the actual runtime implementation could be installed in different path.

slavafomin avatar Feb 05 '21 13:02 slavafomin

Inside a large monorepo, it is quite common that you have both sass and node-sass installed and accessible by any package. Without a config for sass selector, it is not possible for some one to use 'sass' instead of 'node-sass'.

m1heng avatar Aug 02 '21 08:08 m1heng