Skip to content

Commit

Permalink
fix(dev build): reserving unused port vuejs#26
Browse files Browse the repository at this point in the history
  • Loading branch information
FadySamirSadek committed Apr 14, 2018
1 parent 86d4055 commit ac68434
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
const serveStatic = require('koa-static')
const HTMLPlugin = require('html-webpack-plugin')
const history = require('connect-history-api-fallback')
const portfinder = require('portfinder')

const prepare = require('./prepare')
const HeadPlugin = require('./webpack/HeadPlugin')
Expand Down Expand Up @@ -71,7 +72,12 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
}

const compiler = webpack(config)
const port = cliOptions.port || options.siteConfig.port || 8080
portfinder.basePort = cliOptions.port || options.siteConfig.port || 8080
const port = await portfinder.getPortPromise()
.then((port) => {
return port
})
.catch(err => console.log(err))

let isFirst = true
compiler.hooks.done.tap('vuepress', () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"nprogress": "^0.2.0",
"object-assign": "^4.1.1",
"optimize-css-assets-webpack-plugin": "^4.0.0",
"portfinder": "^1.0.13",
"postcss-loader": "^2.1.3",
"prismjs": "^1.13.0",
"register-service-worker": "^1.2.0",
Expand Down

0 comments on commit ac68434

Please sign in to comment.