Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dart sass only #321

Open
TeoTN opened this issue Sep 21, 2020 · 4 comments · May be fixed by #361
Open

Use dart sass only #321

TeoTN opened this issue Sep 21, 2020 · 4 comments · May be fixed by #361

Comments

@TeoTN
Copy link

TeoTN commented Sep 21, 2020

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?

@shalldie
Copy link

I tried before, just replace node-sass with sass

@vincentbriglia
Copy link

vincentbriglia commented Nov 11, 2020

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:

const sassModuleIds = ['node-sass', 'sass']
export default {
name: 'sass',
test: /\.(sass|scss)$/,
process({ code }) {
return new Promise((resolve, reject) => {
const sass = loadSassOrThrow()

function loadSassOrThrow() {
// Loading one of the supported modules
for (const moduleId of sassModuleIds) {
const module = loadModule(moduleId)
if (module) {
return module
}
}

@slavafomin
Copy link
Contributor

slavafomin commented Feb 5, 2021

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.

@wardpeet wardpeet linked a pull request Mar 21, 2021 that will close this issue
@m1heng
Copy link

m1heng commented Aug 2, 2021

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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants