Created
December 14, 2014 17:49
-
-
Save gaearon/15bbedb69c204d7fc318 to your computer and use it in GitHub Desktop.
WebpackDevServer + pushState hook
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
server = new WebpackDevServer(webpack(config), { | |
contentBase: contentBase, | |
publicPath: config.output.publicPath, | |
hot: true | |
}); | |
server.listen(port, '0.0.0.0'); | |
server.app.use(function pushStateHook(req, res, next) { | |
var ext = path.extname(req.url); | |
if ((ext === '' || ext === '.html') && req.url !== '/') { | |
req.pipe(request(localURL)).pipe(res); | |
} else { | |
next(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are path and request variables? Can you provide imports if needed.