问题描述

在vite+vue3+ts的项目中,使用Sass,在项目启动,打开页面的时候,编辑器控制台报错The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.

解决

通过vite的官网描述(默认使用的api模式是legacy)
在这里插入图片描述
所以只需要在vite项目中的配置文件中添加对应的配置

css: {
      preprocessorOptions: {
        scss: {
          // 解决The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. 警告
          // 使用现代编译器
          api: 'modern-compiler',
        },
      },
}

结尾

路漫漫其修远兮

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐