3.0.0-rc.3
https://webpack.js.org/configuration/dev-server/#devserver-before
Add:
devServer: {
before(app, server) {
server.sockWrite(server.sockets, "content-changed");
}
}
to vue.config.js
file.
sockWrite method on server is hit successfully
server
is undefined
The webpack docs that you linked to don't indicate that there is a second argument, what makes you think it should be there?
Okay so I did some digging, it seems that the devserver indeed passes itself as the second argument, but that's undocumented:
https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L339
We can fix it here:
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/serve.js#L135-L147
labelled as an enhancement since this devserver api is undocumented and therefore not a bug imho.
Most helpful comment
Okay so I did some digging, it seems that the devserver indeed passes itself as the second argument, but that's undocumented:
https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L339
We can fix it here:
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/serve.js#L135-L147