File tree Expand file tree Collapse file tree 5 files changed +11
-1
lines changed Expand file tree Collapse file tree 5 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ Usage: vue-cli-service serve [options]
3232Options:
3333
3434 --open open browser on server start
35+ --copy copy url to clipboard on server start
3536 --mode specify env mode (default: development)
3637 --host specify host (default: 0.0.0.0)
3738 --port specify port (default: 8080)
Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ serve a .js or .vue file in development mode with zero config
174174Options:
175175
176176 -o, --open Open browser
177+ -c, --copy Copy local url to clipboard
177178 -h, --help output usage information
178179```
179180
Original file line number Diff line number Diff line change @@ -159,10 +159,16 @@ module.exports = (api, options) => {
159159 return
160160 }
161161
162+ let copied = ''
163+ if ( isFirstCompile && args . copy ) {
164+ require ( 'clipboardy' ) . write ( urls . localUrlForBrowser )
165+ copied = chalk . dim ( '(copied to clipboard)' )
166+ }
167+
162168 console . log ( )
163169 console . log ( [
164170 ` App running at:` ,
165- ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ` ,
171+ ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ${ copied } ` ,
166172 ` - Network: ${ chalk . cyan ( urls . lanUrlForTerminal ) } `
167173 ] . join ( '\n' ) )
168174 console . log ( )
Original file line number Diff line number Diff line change 3131 "cache-loader" : " ^1.2.2" ,
3232 "case-sensitive-paths-webpack-plugin" : " ^2.1.2" ,
3333 "chalk" : " ^2.4.1" ,
34+ "clipboardy" : " ^1.2.3" ,
3435 "cliui" : " ^4.1.0" ,
3536 "copy-webpack-plugin" : " ^4.5.1" ,
3637 "css-loader" : " ^0.28.11" ,
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ program
8282 . command ( 'serve [entry]' )
8383 . description ( 'serve a .js or .vue file in development mode with zero config' )
8484 . option ( '-o, --open' , 'Open browser' )
85+ . option ( '-c, --copy' , 'Copy local url to clipboard' )
8586 . action ( ( entry , cmd ) => {
8687 loadCommand ( 'serve' , '@vue/cli-service-global' ) . serve ( entry , cleanArgs ( cmd ) )
8788 } )
You can’t perform that action at this time.
0 commit comments