Skip to content

Commit 20159d3

Browse files
Added a parameter to disable serve console message (vuejs#3726)
1 parent 206803c commit 20159d3

File tree

1 file changed

+33
-28
lines changed
  • packages/@vue/cli-service/lib/commands

1 file changed

+33
-28
lines changed

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

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = (api, options) => {
1919
options: {
2020
'--open': `open browser on server start`,
2121
'--copy': `copy url to clipboard on server start`,
22+
'--noinstructions': `disable logging instructions on first compilation complete and on every HMR recompilation`,
2223
'--mode': `specify env mode (default: development)`,
2324
'--host': `specify host (default: ${defaults.host})`,
2425
'--port': `specify port (default: ${defaults.port})`,
@@ -206,43 +207,47 @@ module.exports = (api, options) => {
206207
}
207208
}
208209

209-
const networkUrl = publicUrl
210-
? publicUrl.replace(/([^/])$/, '$1/')
211-
: urls.lanUrlForTerminal
212-
213-
console.log()
214-
console.log(` App running at:`)
215-
console.log(` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`)
216-
if (!isInContainer) {
217-
console.log(` - Network: ${chalk.cyan(networkUrl)}`)
218-
} else {
210+
if(!args.noinstructions) {
211+
const networkUrl = publicUrl
212+
? publicUrl.replace(/([^/])$/, '$1/')
213+
: urls.lanUrlForTerminal
214+
219215
console.log()
220-
console.log(chalk.yellow(` It seems you are running Vue CLI inside a container.`))
221-
if (!publicUrl && options.publicPath && options.publicPath !== '/') {
222-
console.log()
223-
console.log(chalk.yellow(` Since you are using a non-root publicPath, the hot-reload socket`))
224-
console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`))
225-
console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`))
216+
console.log(` App running at:`)
217+
console.log(` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`)
218+
if (!isInContainer) {
219+
console.log(` - Network: ${chalk.cyan(networkUrl)}`)
220+
} else {
226221
console.log()
222+
console.log(chalk.yellow(` It seems you are running Vue CLI inside a container.`))
223+
if (!publicUrl && options.publicPath && options.publicPath !== '/') {
224+
console.log()
225+
console.log(chalk.yellow(` Since you are using a non-root publicPath, the hot-reload socket`))
226+
console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`))
227+
console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`))
228+
console.log()
229+
}
230+
console.log(chalk.yellow(` Access the dev server via ${chalk.cyan(
231+
`${protocol}://localhost:<your container's external mapped port>${options.publicPath}`
232+
)}`))
227233
}
228-
console.log(chalk.yellow(` Access the dev server via ${chalk.cyan(
229-
`${protocol}://localhost:<your container's external mapped port>${options.publicPath}`
230-
)}`))
234+
console.log()
231235
}
232-
console.log()
233236

234237
if (isFirstCompile) {
235238
isFirstCompile = false
236239

237-
if (!isProduction) {
238-
const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : hasProjectPnpm(api.getCwd()) ? `pnpm run build` : `npm run build`
239-
console.log(` Note that the development build is not optimized.`)
240-
console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
241-
} else {
242-
console.log(` App is served in production mode.`)
243-
console.log(` Note this is for preview or E2E testing only.`)
240+
if(!args.noinstructions) {
241+
if (!isProduction) {
242+
const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : hasProjectPnpm(api.getCwd()) ? `pnpm run build` : `npm run build`
243+
console.log(` Note that the development build is not optimized.`)
244+
console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
245+
} else {
246+
console.log(` App is served in production mode.`)
247+
console.log(` Note this is for preview or E2E testing only.`)
248+
}
249+
console.log()
244250
}
245-
console.log()
246251

247252
if (args.open || projectDevServerOptions.open) {
248253
const pageUri = (projectDevServerOptions.openPage && typeof projectDevServerOptions.openPage === 'string')

0 commit comments

Comments
 (0)