-
-
Notifications
You must be signed in to change notification settings - Fork 429
Description
Hey 👋
Create React App users have been very vocal about wanting to have Sass supported out of the box.
My personal concerns about node-sass
haven't changed: it’s unfortunate to impose downloading a binary on each our user, and especially unfair to subject them to build issues like sass/node-sass#2146 if they’re not even planning to rely on Sass.
But since the demand for Sass isn’t going away, I’d like to make it opt-in for our users. The ideal user experience would be that they don’t need to download node-sass
by default and don’t see any peer dependency warnings, but if they attempt to import a Sass file, they will see an error message telling them to install a compatible version of node-sass
.
The biggest roadblock to this experience is that sass-loader
will just crash without node-sass
installed. We could prevent this by putting our own custom loader in front of it, but this still doesn’t solve the scary peerDependency
warning coming from our package if it depends on sass-loader
but not node-sass
. And, as I mentioned above, we don’t want to force our users to install node-sass
unless they actually plan to use it.
Here is how sass-loader
works today:
- It has a
peerDependency
onnode-sass
- If
node-sass
doesn't exist,sass-loader
crashes
Here is my proposal for how it could work:
- It has no
peerDependency
onnode-sass
- The import of
node-sass
is wrapped in atry
/catch
- If
node-sass
is missing orrequire('node-sass').info
doesn’t match the compatible range, the loader issues a compilation error telling the user to install a compatible version ofnode-sass
This allows tools like Create React App to depend on sass-loader
by default without creating hurdles for users who don’t want it. What do you think? We’d be happy to send a PR ourselves if you can get behind this change in behavior.