Closed daiwanxing closed 1 month ago
The deprecations options are only available in the modern JS API.
Vite is still using the legacy JS API, so you'll need to wait until https://github.com/vitejs/vite/issues/7116 is resolved to use these flags.
Hi, @daiwanxing you can try this:
*vite.config.js
const SCSS_Logger = {
warn(message, options) {
// Mute "Mixed Declarations" warning
if (options.deprecation && message.includes('mixed-decls')) {
return
}
// List all other warnings
console.warn(`▲ [WARNING]: ${message}`);
},
};
export default defineConfig({
plugins: [],
css: {
preprocessorOptions: {
scss: {
logger: SCSS_Logger,
},
},
},
});
Hi, @daiwanxing you can try this:
*vite.config.js
const SCSS_Logger = { warn(message, options) { // Mute "Mixed Declarations" warning if (options.deprecation && message.includes('mixed-decls')) { return } // List all other warnings console.warn(`▲ [WARNING]: ${message}`); }, }; export default defineConfig({ plugins: [], css: { preprocessorOptions: { scss: { logger: SCSS_Logger, }, }, }, });
Thank you, this is a good workaround!
Finally a workaround, I wish this was clear in the documentation that scss support is not up to date and so preprocessorOptions wont work as expected.
You have to use at leaset the "modern" API:
export default defineConfig({
css: {
preprocessorOptions: {
scss: {
api: 'modern',
silenceDeprecations: ['mixed-decls'],
},
}
}
}
See also Shared Options | Vite.
just now upgrade my dependency of sass to the latest version (
1.77.8
) and restart, the app terminal output some warnings that i've never got.I have no time to solve these warnings, the easily way to me is make these warnings keep silence.
I followed the document instructions. but it's not work, I still got bunch of warnings. Is there something wrong with my configuration?