mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-05-24 22:48:27 -05:00
feat: add --copy option for vue-cli-service serve (#1355)
This commit is contained in:
@@ -32,6 +32,7 @@ Usage: vue-cli-service serve [options]
|
||||
Options:
|
||||
|
||||
--open open browser on server start
|
||||
--copy copy url to clipboard on server start
|
||||
--mode specify env mode (default: development)
|
||||
--host specify host (default: 0.0.0.0)
|
||||
--port specify port (default: 8080)
|
||||
|
||||
@@ -174,6 +174,7 @@ serve a .js or .vue file in development mode with zero config
|
||||
Options:
|
||||
|
||||
-o, --open Open browser
|
||||
-c, --copy Copy local url to clipboard
|
||||
-h, --help output usage information
|
||||
```
|
||||
|
||||
|
||||
@@ -159,10 +159,16 @@ module.exports = (api, options) => {
|
||||
return
|
||||
}
|
||||
|
||||
let copied = ''
|
||||
if (isFirstCompile && args.copy) {
|
||||
require('clipboardy').write(urls.localUrlForBrowser)
|
||||
copied = chalk.dim('(copied to clipboard)')
|
||||
}
|
||||
|
||||
console.log()
|
||||
console.log([
|
||||
` App running at:`,
|
||||
` - Local: ${chalk.cyan(urls.localUrlForTerminal)}`,
|
||||
` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`,
|
||||
` - Network: ${chalk.cyan(urls.lanUrlForTerminal)}`
|
||||
].join('\n'))
|
||||
console.log()
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"cache-loader": "^1.2.2",
|
||||
"case-sensitive-paths-webpack-plugin": "^2.1.2",
|
||||
"chalk": "^2.4.1",
|
||||
"clipboardy": "^1.2.3",
|
||||
"cliui": "^4.1.0",
|
||||
"copy-webpack-plugin": "^4.5.1",
|
||||
"css-loader": "^0.28.11",
|
||||
|
||||
@@ -82,6 +82,7 @@ program
|
||||
.command('serve [entry]')
|
||||
.description('serve a .js or .vue file in development mode with zero config')
|
||||
.option('-o, --open', 'Open browser')
|
||||
.option('-c, --copy', 'Copy local url to clipboard')
|
||||
.action((entry, cmd) => {
|
||||
loadCommand('serve', '@vue/cli-service-global').serve(entry, cleanArgs(cmd))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user