Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created October 12, 2016 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dengjonathan/78e6bfff17f1679224dfd48328478648 to your computer and use it in GitHub Desktop.
Save dengjonathan/78e6bfff17f1679224dfd48328478648 to your computer and use it in GitHub Desktop.
App.js file to instantiate a server and allow hot module reloading
const Server = require('./server.js')
const port = (process.env.PORT || 8080)
const app = Server.app()
if (process.env.NODE_ENV !== 'production') {
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const config = require('../webpack.deployment.config.js')
const compiler = webpack(config)
app.use(webpackHotMiddleware(compiler))
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPathdist
}))
}
app.listen(port)
console.log(`Listening at http://localhost:${port}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment