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

Codesandbox not recognizing sass modules with @use when using dart-sass #4742

Closed
jjloneman opened this issue Aug 19, 2020 · 10 comments · Fixed by #5991
Closed

Codesandbox not recognizing sass modules with @use when using dart-sass #4742

jjloneman opened this issue Aug 19, 2020 · 10 comments · Fixed by #5991

Comments

@jjloneman
Copy link

Problem

Sass released a module system where @use can replace @import amongst other features.

Unfortunately, node-sass does not support the new module system, only dart-sass.

The sass npm module is the implementation of dart-sass, which is supported by create-react-app.

Code Sandbox Example

Using the react template in codesandbox and adding the bootstrap and sass packages, adding styles.scss with the @import rule works:

@import "~bootstrap/scss/bootstrap";

but using the @use rule does not work:

@use "~bootstrap/scss/bootstrap";

.App {
  @include bootstrap.float-right();
}

and displays the following error:

image

Local Example

Exporting the sandbox to a zip through File > Export to Zip and running npm install and npm start works (the text is supposed to float right):

image

@SaraVieira
Copy link
Contributor

Hey!

We currently do not support dart-sass as we run all the sass compilations through node and web workers

As soon as this is supported in node-sass it will be added, I subscribed to the issue mentioned so we can upgrade as soon as it's added

Sorry for the issue

@Donov4n
Copy link

Donov4n commented Nov 2, 2020

Sadly, node-sass is deprecated and the module support will probably never be implemented.

Is a migration to dart-sass being considered?

@wesgro
Copy link

wesgro commented Jun 22, 2021

Could this be re-opened?

node-sass is dead and not being able to use sass modules in a codesandbox gives me bad feels.

@jjloneman
Copy link
Author

Regarding @Donov4n's and @wesgro's comments, node-sass is indeed deprecated. As per their GitHub:

Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

@SaraVieira, you mentioned:

We currently do not support dart-sass as we run all the sass compilations through node and web workers

but is there a specific reason that sass compilations through node can't use dart-sass? According to their readme, their JavaScript api is fully compatible with Node Sass:

When installed via npm, Dart Sass supports a JavaScript API that's fully
compatible with Node Sass
(with a few exceptions listed below), with support
for both the render() and renderSync() functions. See the Sass
website
for full API documentation!

Note however that by default, renderSync() is more than twice as fast as
render()
due to the overhead of asynchronous callbacks. To avoid this
performance hit, render() can use the fibers package to call
asynchronous importers from the synchronous code path. To enable this, pass the
Fiber class to the fiber option:

var sass = require("sass");
var Fiber = require("fibers");

sass.render({
  file: "input.scss",
  importer: function(url, prev, done) {
    // ...
  },
  fiber: Fiber
}, function(err, result) {
  // ...
});

They also have a standalone executable to compile sass files:

Dart Sass's stand-alone command-line executable uses the blazing-fast Dart VM to compile your stylesheets. To install Dart Sass on the command line, check out the installation instructions. Once you've got it running, you can use it compile files:

sass source/index.scss css/index.css

@Aleksandyr
Copy link

Aleksandyr commented Jul 21, 2021

@SaraVieira Why don't you reopen this issue as more and more people rely on the new dart-sass compiler?

@SaraVieira
Copy link
Contributor

@CompuIves @christianalfoni Should this be reopened? Is there a way to get dart sass in CodeSandbox?

@CompuIves
Copy link
Member

CompuIves commented Jul 21, 2021 via email

@Aleksandyr
Copy link

@CompuIves @SaraVieira at least we can reopen the issues so that the users know you are working on it.

@SaraVieira SaraVieira reopened this Jul 21, 2021
@SaraVieira
Copy link
Contributor

If there is a way then sure! It's reopened!

@CompuIves
Copy link
Member

Thanks a lot @SaraVieira ❤️ . This is a good place to track @DeMoorJasper 😄

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.

6 participants