Skip to content

Commit

Permalink
fix(dev build): use portfinder (#30)
Browse files Browse the repository at this point in the history
close #26
  • Loading branch information
FadySamirSadek authored and yyx990803 committed Apr 15, 2018
1 parent be0aa9f commit f2a8229
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 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,8 @@ 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()

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 @@ -70,6 +70,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
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ async-limiter@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"

async@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
Expand Down Expand Up @@ -4229,6 +4233,14 @@ pn@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"

portfinder@^1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"
dependencies:
async "^1.5.2"
debug "^2.2.0"
mkdirp "0.5.x"

posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
Expand Down

0 comments on commit f2a8229

Please sign in to comment.