This works for me with webpack 4.x:
let config = {
// ...
plugins: [
// ...
{ // anonymous plugin
apply(compiler) {
compiler.hooks.beforeRun.tapAsync('MyCustomBeforeRunPlugin', function(compiler, callback) {
// debugger
console.dir(compiler.options)
callback()
})
},
}
]
}
When you uncomment the debugger
statement and run the build with --inspect-brk
flag (node --inspect-brk run-webpack.js
), you can also see it in Chrome devtools on chrome://inspect/
page (useful to inspect the functions and object instances that are not serializable to the console).