使用Live Sass编译器(VS代码扩展)还是通过npm安装并运行Sass更好?(+提示如何从node-sass更改为dart-sass) [英] Is it better to use the Live Sass Compiler (VS Code extension) or to install and run Sass via npm? (+ tips how to change from node-sass to dart-sass)

查看:194
本文介绍了使用Live Sass编译器(VS代码扩展)还是通过npm安装并运行Sass更好?(+提示如何从node-sass更改为dart-sass)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上一门有关高级CSS和Sass的在线课程,发现它在课程中的显示方式有点过时了.

I am doing an online course on Advanced CSS and Sass and found out that the way it is shown in the course is a bit outdated.

本课程在依赖项中使用node-sass,已弃用.对此的直接替代方法是使用Dart-sass(最后我会写出步骤,也许有人会从中受益:))

The course uses node-sass in the dependencies, which is deprecated. A direct alternative to this would be to use Dart-sass (I will write my steps to do so in the end, maybe someone will benefit from this :))

另一种选择是使用VS代码扩展"Live Sass Compiler".似乎该选项已被广泛接受.

Another alternative is to use the VS Code Extension "Live Sass Compiler". It seems that this option is quite well accepted.

但是,我想知道这些选择有什么好处和区别.例如.昨天我在扩展程序上遇到了一些麻烦,然后将dart sass用作依赖项,并以此方式解决了我的问题.也许这是由于我的代码中的错误所致,但是仍然使我有这个问题,我认为将来其他人可能会遇到同样的问题.

However, I wonder what benefits and differences these options have. E.g. I had some troubles with the extension yesterday and then used the dart sass as a dependency and solved my problem this way. Maybe this was due to something wrong in my code, but still, it left me with this question and I think others might have the same in the future.

PS:这是我的第一个问题,如果我做错了,请不要烤我:D

PS: It is my first question here, don't roast me if I did something wrong :D

对于那些对如何将代码从node-sass更改为dart-sass感兴趣的人,这里是一些步骤(至少对我来说,这些是我在课程中所做的步骤):

For those interested in how to change the code from node-sass to dart-sass here are the steps (at least for me these were the steps in the course I did):

  1. 使用命令行安装dart sass: npm i -D sass
  2. 将显示" node-sass "的脚本更改为 sass (在package.json中)
  3. watch:sass 脚本中的 -w 更改为-watch (在package.json中)
  4. 您也可以执行 npm卸载node-sass 来摆脱它
  1. Install dart sass using the command line: npm i -D sass
  2. Change your scripts where it says node-sass to just be sass (in package.json)
  3. Change the -w in your watch:sass script to --watch (in package.json)
  4. You can also do npm uninstall node-sass to get rid of it

推荐答案

如果您想将最新版本的Dart SASS与"Live Sass编译器"一起使用,则需要注意该版本.多年来一直不支持最受欢迎的版本,因此它不支持Dart Sass.

If you want to use the most actual version Dart SASS with 'Live Sass Compiler' you need to take care about the version. The most popular version is not supported for years so it does not support Dart Sass.

但是有一个支持的分支,作为分支,您可以使用相同的设置.

But there is a fork which is supported and as fork you can use same settings.

对于有关NPM和Live Sass编译器的问题:都是Sass的Javascript版本.作为Javascript版本,它们的速度不像在系统上直接安装SASS一样快.Javascript版本本身之间的差异没有那么大.因此,我认为NPM和Live Sass编译器之间的最佳选择是使用Live Sass Compiler(派生版本!),因为它已集成到编辑器中,并且可以从那里直接直接使用.

To your Question about NPM and Live Sass Compiler: both are Javascript Version off Sass. As Javascript versions they are not as fast as if you install SASS direct on your System. The difference between Javascript vesion itself its not as big. So I think the best choice between NPM and Live Sass compiler is to use Live Sass Compiler (the forked version!) as it is integrated to the editor and easier to use direct from there.

如果您需要更快的解决方案,则应该安装原始版本.这并不像听起来那样困难.此外,还有一个VS Code扩展名,可以轻松地从VS Code直接使用该原始安装版本.

If you need a faster solution you really should install the original version. That is not as difficult as it sounds. And there is a VS Code Extension as well wich make it possible to use that original installed version easy direct up from VS Code.

详细信息:

直接在系统上安装SASS:
https://sass-lang.com/install

Install SASS direct on your system:
https://sass-lang.com/install

有关命名的VS Code扩展的信息:
https://stackoverflow.com/a/66207572/9268485

Information to the named VS Code extension:
https://stackoverflow.com/a/66207572/9268485

这篇关于使用Live Sass编译器(VS代码扩展)还是通过npm安装并运行Sass更好?(+提示如何从node-sass更改为dart-sass)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆