从node-sass迁移到dart-sass

2021-12-29  本文已影响0人  golddream_y
库名 库状态 描述
node-sass 废弃 sass预处理器的编译器,是调用libsass的node中间件。官方说明:Node-sass is a library that provides binding for Node.js to LibSass, the C version of the popular stylesheet preprocessor, Sass.
Dart-sass 维护中 sass的dart实现。官方说明:A Dart implementation of Sass.
Sass 维护中 sass预处理器的编译器,node实现。

以上三个库均为官方提供,上述表格为截止 2020-12-29 的状态。

为什么迁移?

如何迁移?

How do I migrate?

If you’re a user of Node Sass, migrating to Dart Sass is straightforward: just replace node-sass in your package.json file with sass. Both packages expose the same JavaScript API.

If you’re using the SassC command-line interface, you can switch to Dart Sass’s CLI. Note that this doesn’t have exactly the same interface as SassC, so you may need to change a few flags.

If you’re using LibSass through a wrapper library in another language, you can either switch to the Dart Sass CLI or ask the maintainer of the LibSass wrapper to convert it to a host for the Sass embedded protocol. The embedded protocol allows any language to provide a native API that calls out to Dart Sass.

Please note that because activity on LibSass has been low for several years, it has a number of outstanding bugs and behavioral variations from the Sass spec. You may need to make minor updates to stylesheets to make them compatible with Dart Sass. See this list of major compatibility issues for reference.

迁移注意事项:

  1. Deep-selectors检查: /deep/在dart-sass中不受支持,使用良好的选择器结构避免或使用相关领域loader独有的语法,如:https://vue-loader.vuejs.org/guide/scoped-css.html#deep-selectors
上一篇 下一篇

猜你喜欢

热点阅读