Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Fix development server not starting up after Webpack 2 update 😭
Browse files Browse the repository at this point in the history
  • Loading branch information
pirelenito committed Apr 7, 2017
1 parent e2401ad commit 588ec59
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/run/development-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ import Server from 'webpack-dev-server'
export default (saguiConfig, webpackConfig) => new Promise((resolve, reject) => {
const options = {
hot: true,
historyApiFallback: saguiConfig.pages && saguiConfig.pages[0] && `${saguiConfig.pages[0]}.html`,
noInfo: true,
...saguiConfig.develop
}

try {
new Server(webpack(setupHMR(webpackConfig)), options).listen(saguiConfig.port, '0.0.0.0', (err) => {
const server = new Server(webpack(setupHMR(webpackConfig)), options)

server.listeningApp.on('error', function (e) {
if (e.code === 'EADDRINUSE') {
logError(`Server failed to started at http://localhost:${saguiConfig.port}. Port already used.`)
reject(new Error('This port is already used'))
}
})

server.listen(saguiConfig.port, '0.0.0.0', (err) => {
if (err) {
logError(`Server failed to started at http://localhost:${saguiConfig.port}`)
reject(err)
Expand All @@ -22,6 +31,8 @@ export default (saguiConfig, webpackConfig) => new Promise((resolve, reject) =>
}
})
} catch (e) {
logError('Server failed to start.')
logError(e.stack || e)
reject(e)
}
})
Expand Down

0 comments on commit 588ec59

Please sign in to comment.