Skip to content

Instantly share code, notes, and snippets.

@messutied
Last active April 1, 2017 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messutied/ee2f4bd5f3d8efb0d982c665f8a2097b to your computer and use it in GitHub Desktop.
Save messutied/ee2f4bd5f3d8efb0d982c665f8a2097b to your computer and use it in GitHub Desktop.
react-hot-reloader with custom server proxying to webpack-dev-server
const express = require('express');
const url = require('url');
const path = require('path');
const app = express();
if (process.env.NODE_ENV !== 'production') {
app.use('/assets', require('proxy-middleware')(url.parse('http://localhost:8080/assets')));
} else {
app.use('/assets', express.static(path.resolve(__dirname, '../www/assets')));
}
app.get('/', (req, res) => {
res.sendFile(path.resolve(__dirname, '../www/index.html'));
});
app.listen(3000, () => console.log('Server listening on port 3000'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment