Last active
November 3, 2017 02:21
-
-
Save eqyiel/e3373cdeb2cd7bac76f758f3d1d1e92c to your computer and use it in GitHub Desktop.
How to monkeypatch webpack-dev-server ^2.9.3 for use with react-devtools
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
/** | |
* webpack.config.js | |
*/ | |
const webpack = require('webpack'); | |
const path = require('path'); | |
const { stripIndent } = require('common-tags'); | |
module.exports = (env, { p: production }) => ({ | |
...{ | |
entry: path.resolve(__dirname, './index.js'), | |
output: { | |
filename: 'bundle.js', | |
}, | |
// ... other config | |
devServer: { | |
hot: true, | |
open: true, | |
before: (_, devServer) => { | |
devServer.serveMagicHtml = (req, res, next) => { | |
res.end( | |
stripIndent` | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<script type="text/javascript" charset="utf-8" src="http://localhost:8097"></script> | |
</head> | |
<body> | |
<script type="text/javascript" charset="utf-8" src="${req.path}.js${req | |
._parsedUrl.search || ''}"></script> | |
</body> | |
</html>`, | |
); | |
}; | |
}, | |
openPage: 'webpack-dev-server/bundle', | |
overlay: { | |
warnings: true, | |
errors: true, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment