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]
32
32
Options:
33
33
34
34
--open open browser on server start
35
+ --copy copy url to clipboard on server start
35
36
--mode specify env mode (default: development)
36
37
--host specify host (default: 0.0.0.0)
37
38
--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
174
174
Options:
175
175
176
176
-o, --open Open browser
177
+ -c, --copy Copy local url to clipboard
177
178
-h, --help output usage information
178
179
```
179
180
Original file line number Diff line number Diff line change @@ -159,10 +159,16 @@ module.exports = (api, options) => {
159
159
return
160
160
}
161
161
162
+ let copied = ''
163
+ if ( isFirstCompile && args . copy ) {
164
+ require ( 'clipboardy' ) . write ( urls . localUrlForBrowser )
165
+ copied = chalk . dim ( '(copied to clipboard)' )
166
+ }
167
+
162
168
console . log ( )
163
169
console . log ( [
164
170
` App running at:` ,
165
- ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ` ,
171
+ ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ${ copied } ` ,
166
172
` - Network: ${ chalk . cyan ( urls . lanUrlForTerminal ) } `
167
173
] . join ( '\n' ) )
168
174
console . log ( )
Original file line number Diff line number Diff line change 31
31
"cache-loader" : " ^1.2.2" ,
32
32
"case-sensitive-paths-webpack-plugin" : " ^2.1.2" ,
33
33
"chalk" : " ^2.4.1" ,
34
+ "clipboardy" : " ^1.2.3" ,
34
35
"cliui" : " ^4.1.0" ,
35
36
"copy-webpack-plugin" : " ^4.5.1" ,
36
37
"css-loader" : " ^0.28.11" ,
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ program
82
82
. command ( 'serve [entry]' )
83
83
. description ( 'serve a .js or .vue file in development mode with zero config' )
84
84
. option ( '-o, --open' , 'Open browser' )
85
+ . option ( '-c, --copy' , 'Copy local url to clipboard' )
85
86
. action ( ( entry , cmd ) => {
86
87
loadCommand ( 'serve' , '@vue/cli-service-global' ) . serve ( entry , cleanArgs ( cmd ) )
87
88
} )
You can’t perform that action at this time.
0 commit comments