Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tilde imports with the dart sass CLI

I'm upgrading an old system with many of these:

@import "~bootstrap/scss/mixins";

That fails when compiling with the dart-sass CLI.

I used to use node-sass, and packages like node-sass-tilde-importer and node-sass-package-importer to help with that syntax. They don't seem to work for dart-sass.

Given that I'm now using the dart sass CLI, how do I deal with this?

like image 752
lonix Avatar asked Oct 31 '25 10:10

lonix


1 Answers

The solution is simple, but unfortunately does not support the tilde syntax.

The scss file should have this:

@import "foo/bar";            // <--- must remove tilde

And the cli syntax is:

sass --load-path=path/to/node_modules SomeFile.scss SomeFile.css

For completeness, the obvious other solution is:

@import "../../../node_modules/foo/bar";
like image 86
lonix Avatar answered Nov 03 '25 11:11

lonix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!