Last active
April 1, 2017 08:42
-
-
Save messutied/ee2f4bd5f3d8efb0d982c665f8a2097b to your computer and use it in GitHub Desktop.
react-hot-reloader with custom server proxying to webpack-dev-server
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 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