Skip to content

fix: use setupMiddlewares, avoid dev server deprecation warnings #6907

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

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/@vue/cli-service/lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,23 @@ module.exports = (api, options) => {
open: args.open || projectDevServerOptions.open,
setupExitSignals: true,

// eslint-disable-next-line no-shadow
onBeforeSetupMiddleware (server) {
setupMiddlewares (middlewares, devServer) {
// launch editor support.
// this works with vue-devtools & @vue/cli-overlay
server.app.use('/__open-in-editor', launchEditorMiddleware(() => console.log(
devServer.app.use('/__open-in-editor', launchEditorMiddleware(() => console.log(
`To specify an editor, specify the EDITOR env variable or ` +
`add "editor" field to your Vue project config.\n`
)))

// allow other plugins to register middlewares, e.g. PWA
// todo: migrate to the new API interface
api.service.devServerConfigFns.forEach(fn => fn(server.app, server))
api.service.devServerConfigFns.forEach(fn => fn(devServer.app, devServer))

if (projectDevServerOptions.onBeforeSetupMiddleware) {
projectDevServerOptions.onBeforeSetupMiddleware(server)
if (projectDevServerOptions.setupMiddlewares) {
return projectDevServerOptions.setupMiddlewares(middlewares, devServer)
}

return middlewares
}
}), compiler)

Expand Down