-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
What are the equivalent of webpack-serve's "on" hooks? #1509
Comments
@marcofugaro it is feature, can you describe use case for this? |
Sure thing! Basically I was using these hooks to show only the information I need to the console (same thing I was using webpack-command for). Here is config I was using, take a look at the comments: const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages')
const openBrowser = require('react-dev-utils/openBrowser')
const prettyMs = require('pretty-ms')
module.exports = {
serve: {
port: 8080,
// don't show all the default webpack stuff
logLevel: 'silent',
hotClient: {
logLevel: 'silent',
},
devMiddleware: {
logLevel: 'silent',
},
on: {
listening: ({ options }) => {
// try to open into the already existing tab
openBrowser(`http://localhost:${options.port}`)
},
'build-finished': ({ stats }) => {
if (stats.hasErrors()) {
return
}
const time = prettyMs(stats.endTime - stats.startTime)
console.log(`Compiled successfully in ${time}`)
},
'compiler-error': stats => {
// format the errors in a nicer way
const messages = formatWebpackMessages(stats.json)
console.log(messages.errors[0])
},
},
},
} |
This comment has been minimized.
This comment has been minimized.
what about the solution given in this issue: #132 ?
|
@polco as I already specified, I don't want to call webpack from node, I have a simple webpack.config.js and want to keep it that way. |
My bad |
PR welcome, it is should be not diffucult |
@evilebottnawi Could you stop writing PR welcome on every issue. |
@atilkan What is the problem? |
I want to close this issue in favor of webpack's built-in hooks, also we have some callbacks, like |
Sorry if this is a question, but I can't find a solution.
I found myself migrating back to webpack-dev-server after webpack-serve was deprecated. I found really useful to attach hooks in the webpack.config.js without having to touch node at all.
The hooks I used were
on.listening
,on.build-finished
,on.compiler-error
to show custom stats to the console. What are the equilvalent hooks in webpack-dev-server? I only foundafter
that could substitute theon.listening
, how do I attach hooks to the remaining two events, without having to run webpack from node?Another thing I was doing:
How do I do this in webpack-dev-server? How do I get the port from the arguments in
after
?The text was updated successfully, but these errors were encountered: