Created
July 25, 2017 00:29
-
-
Save souporserious/27ed7237d7dcf6a747d7a8c0936b5340 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 path = require('path') | |
const express = require('express') | |
const webpack = require('webpack') | |
const webpackDevMiddleware = require('webpack-dev-middleware') | |
const webpackHotMiddleware = require('webpack-hot-middleware') | |
const config = require('./webpack.config.js') | |
const app = express() | |
const port = 8080 | |
const compiler = webpack(config) | |
const middleware = webpackDevMiddleware(compiler, { | |
publicPath: config.output.publicPath, | |
stats: { | |
colors: true, | |
timings: true, | |
}, | |
}) | |
console.log('Enabling webpack dev middleware') | |
app.use(middleware) | |
console.log('Enabling Webpack Hot Module Replacement (HMR)') | |
app.use(webpackHotMiddleware(compiler)) | |
console.log('Redirecting...') | |
app.get('*', (req, res) => { | |
res.sendFile(path.join(__dirname, 'example/index.html')) | |
}) | |
app.listen(port, '0.0.0.0', err => { | |
if (err) { | |
console.log(err) | |
} | |
console.info('==> 🌎 Server is now running at http://0.0.0.0:%s/', port) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment