Skip to content

Commit 9d5b80d

Browse files
committed
Make changing port from cli possible.
1 parent fb39683 commit 9d5b80d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ $ npm install -g vue-cli
1818
$ vue init webpack my-project
1919
$ cd my-project
2020
$ npm install
21+
# run at default port 8080
2122
$ npm run dev
23+
# run at port 6060
24+
$ npm run dev -- --port 6060
2225
```
2326

24-
If port 8080 is already in use on your machine you must change the port number in `/config/index.js`. Otherwise `npm run dev` will fail.
25-
2627
## What's Included
2728

2829
- `npm run dev`: first-in-class development experience.

template/build/dev-server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ var webpackConfig = {{#if_or unit e2e}}(process.env.NODE_ENV === 'testing' || pr
1616

1717
// default port where dev server listens for incoming traffic
1818
var port = process.env.PORT || config.dev.port
19+
var portIndex = process.argv.indexOf('--port')
20+
if (portIndex !== -1) {
21+
port = process.argv[portIndex + 1] || port;
22+
}
1923
// automatically open browser, if not set will be false
2024
var autoOpenBrowser = !!config.dev.autoOpenBrowser
2125
// Define HTTP proxies to your custom API backend

0 commit comments

Comments
 (0)