修复控制台出现 Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0 的问题

背景

项目使用到Vite5.3.1+Sass,然后突然某天启动项目,控制台出现了这一行报错,百度找了一遍没找到解决方案。
最后去StackOverflow找了一下,解决了。

解决办法

vite.config.js 中添加这一配置即可。

import { defineConfig } from "vite";

export default defineConfig({
  // ...
  css: {
    preprocessorOptions: {
      scss: {
        api: "modern-compiler" // or 'modern'
      }
    }
  },
  // ...
});

原文链接

sass - How to set sassOptions in Vite -Stack Overflow stackoverflow.com

posted @ 2024-09-19 10:19  脆皮鸡  阅读(22364)  评论(2)    收藏  举报