Skip to content

Commit 4580397

Browse files
authored
fix: use setupMiddlewares, avoid dev server deprecation warnings (#6907)
1 parent 8e45e56 commit 4580397

File tree

1 file changed

+7
-6
lines changed
  • packages/@vue/cli-service/lib/commands

1 file changed

+7
-6
lines changed

packages/@vue/cli-service/lib/commands/serve.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,23 @@ module.exports = (api, options) => {
219219
open: args.open || projectDevServerOptions.open,
220220
setupExitSignals: true,
221221

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

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

235-
if (projectDevServerOptions.onBeforeSetupMiddleware) {
236-
projectDevServerOptions.onBeforeSetupMiddleware(server)
234+
if (projectDevServerOptions.setupMiddlewares) {
235+
return projectDevServerOptions.setupMiddlewares(middlewares, devServer)
237236
}
237+
238+
return middlewares
238239
}
239240
}), compiler)
240241

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy