Tilde用飞镖Sass CLI进口

发布于 2025-02-01 02:49:12 字数 422 浏览 5 评论 0原文

我正在升级一个旧的系统,其中包括许多:

@import "~bootstrap/scss/mixins";

使用飞镖sass cli编译时失败。

我曾经使用node-sass,以及node-sass-tilde-importernode-sass-sass-package-importer之类的软件包来帮助该语法。他们似乎不适用于飞镖。

鉴于我现在正在使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悍妇囚夫 2025-02-08 02:49:12

该解决方案很简单,但不幸的是不支持Tilde语法

SCSS文件应该具有以下操作:

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

CLI语法是:

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

为了完整,显而易见的其他解决方案是:

@import "../../../node_modules/foo/bar";

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";
月竹挽风 2025-02-08 02:49:12

Dart Sass CLI?我认为在Dart Sass中无法进行这样的进口。您必须手动进行。

但是有一个SASS迁移器可以修复遗产SASS代码,请尝试一下:

https:// https:// sass -lang.com/documentation/cli/migrator

如果您将其与模块包装串一起使用,这可能会有所帮助:

如何使用webpack,sass-loader和dart sass tilde prefix导入sass

Dart Sass CLI? I think there is no way to import like this in Dart Sass. You have to do it manually.

But there is a Sass migrator to fix legacy sass code, give it a try :

https://sass-lang.com/documentation/cli/migrator

If you are using it with module bundlers, this might help:

How to import sass using tilde prefix with webpack, sass-loader and dart sass

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文