Vue-cli: vue.config.js devServer before() arguments undefined

Created on 13 Jul 2018  路  3Comments  路  Source: vuejs/vue-cli

Version

3.0.0-rc.3

Reproduction link

https://webpack.js.org/configuration/dev-server/#devserver-before

Steps to reproduce

Add:

devServer: {
  before(app, server) {
      server.sockWrite(server.sockets, "content-changed");
  }
}

to vue.config.js file.

What is expected?

sockWrite method on server is hit successfully

What is actually happening?

server is undefined

enhancement cli-service serve

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

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BusyHe picture BusyHe  路  3Comments

jgribonvald picture jgribonvald  路  3Comments

joshuajohnson814 picture joshuajohnson814  路  3Comments

csakis picture csakis  路  3Comments

PrimozRome picture PrimozRome  路  3Comments