Since NextJS log is no longer part of webpack logs, we cannot use FilterWarningsPlugin
. Instead, use node level stdout filter, for example, intercept-stdout
.
First, install package:
$ npm i intercept-stdout --save-dev
Then, for example, to ignore all warnings that contain the word “spida”:
const nextApp = require('next')()
const intercept = require('intercept-stdout')
nextApp.prepare().then(async () => {
// in front of all other code
intercept((text) => {
if (text.match(/spida/)) return ''
return text
})
....
}
And since production doesn’t have these warnings anyway, feel free to add a if (process.env.NODE_ENV === 'development')
in front.