Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to ignore postcss warnings #9597

Closed
4 tasks done
NikolayMakhonin opened this issue Aug 9, 2022 · 2 comments · Fixed by #10108
Closed
4 tasks done

Add an option to ignore postcss warnings #9597

NikolayMakhonin opened this issue Aug 9, 2022 · 2 comments · Fixed by #10108

Comments

@NikolayMakhonin
Copy link

NikolayMakhonin commented Aug 9, 2022

Description

I want to disable unnecessary postcss warning in the console, like this:

[vite:css] C:\projects\my-site\src\styles\mixins.pcss is empty

Suggested solution

I propose to add a new option similar to onwarn in rollup, in which it will be possible to filter postcss warnings. I think the warnings filter should be used here

Alternative

Put this comment into mixins.pcss file: /* The file is empty now */

Additional context

No response

Validations

@sapphi-red
Copy link
Member

This is possible by customLogger option.

import { createLogger, defineConfig } from 'vite';

const logger = createLogger();
const originalWarning = logger.warn;
logger.warn = (msg, options) => {
  if (msg.includes('vite:css') && msg.includes(' is empty')) return;
  originalWarning(msg, options);
};

export default defineConfig({
  customLogger: logger,
});

https://stackblitz.com/edit/vitejs-vite-mjupek?file=vite.config.js&terminal=dev

@bluwy
Copy link
Member

bluwy commented Aug 16, 2022

I feel like customLogger here is the best option as we would have a single point to handle all warnings of a Vite app. It looks like the option isn't documented though, so we could also do that.

@bluwy bluwy added documentation Improvements or additions to documentation feat: css labels Aug 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants