修复控制台出现Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0的问题
背景
项目使用到Vite+Sass,然后突然某天启动项目,控制台出现了这一行报错,找了一遍没找到解决方案。
最后去StackOverflow找了一下,解决了。
修复方式
在 vite.config.js
中添加这一配置即可。
import { defineConfig } from "vite";
export default defineConfig({
// ...
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler" // or 'modern'
}
}
},
// ...
});
LINKS
sass - How to set sassOptions in Vite -Stack Overflow stackoverflow.com