Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress warnings using webpack and post css

How do I suppress warnings generated by webpack loading post css files?

Warning example:

WARNING in ./~/css-loader!./~/postcss-loader!./src/components/Navigator/Navigator.css
postcss-custom-properties: C:\StackData\bd\src\components\Navigator\Navigator.css:33:9: variable '--active' is undefined and
 used without a fallback

My webpack config:

 module: {
    loaders: [
   ...
      {test: /\.css/, loader: 'style-loader!css-loader!postcss-loader'},
   ...
    ]
  },
  postcss: function () {
    return [precss, autoprefixer];
  }
like image 211
Avi Zloof Avatar asked Aug 11 '16 07:08

Avi Zloof


People also ask

How do you add CSS to webpack?

Configure webpack css-loader and style-loader To be able to use CSS in your webpack app, you need to set up a new loader. Out-of-the-box, webpack only understands Javascript and JSON. With a loader, you can translate another type of file to a format that webpack understands and can work with.

What is PostCSS in webpack?

PostCSS is a Node. js tool that transforms your styles using JavaScript plugins. It generates more downloads per week on NPM than other CSS preprocessors like Sass, Less, and Stylus combined.

What is PostCSS loader used for?

PostCSS is: a tool for transforming styles with JS plugins. These plugins can lint your CSS, support variables and mixins, transpile future CSS syntax, inline images, and more.


2 Answers

Can you try adding

module.exports = {
  entry: ...,
  stats: {warnings:false}
  ...
}
like image 179
Pavithra Kodmad Avatar answered Sep 23 '22 02:09

Pavithra Kodmad


You can use the stats.warningsFilter. Try with something like this:

module.exports = {
    ...
    stats: {
        warningsFilter: [
            './~/css-loader!./~/postcss-loader!./src/components/Navigator/Navigator.css'
        ]
    }
    ...
}

You can add anything that appears in the warning, even with a regex or a function. More specific is better.

like image 24
Chema Avatar answered Sep 20 '22 02:09

Chema