Created
October 12, 2016 03:00
-
-
Save dengjonathan/78e6bfff17f1679224dfd48328478648 to your computer and use it in GitHub Desktop.
App.js file to instantiate a server and allow hot module reloading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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