Skip to content

Commit 87d3d75

Browse files
authored
Click to view source from error overlay (facebook#2141)
* Click to view source * Update package.json * Update package.json * Fix lint
1 parent a60dced commit 87d3d75

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/utils/addWebpackMiddleware.js

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const chalk = require('chalk');
1414
const dns = require('dns');
1515
const historyApiFallback = require('connect-history-api-fallback');
1616
const httpProxyMiddleware = require('http-proxy-middleware');
17+
const launchEditor = require('react-dev-utils/launchEditor');
1718
const url = require('url');
1819
const paths = require('../../config/paths');
1920

@@ -145,10 +146,23 @@ function registerProxy(devServer, _proxy) {
145146
});
146147
}
147148

149+
// This is used by the crash overlay.
150+
function launchEditorMiddleware() {
151+
return function(req, res, next) {
152+
if (req.url.startsWith('/__open-stack-frame-in-editor')) {
153+
launchEditor(req.query.fileName, req.query.lineNumber);
154+
res.end();
155+
} else {
156+
next();
157+
}
158+
};
159+
}
160+
148161
module.exports = function addWebpackMiddleware(devServer) {
149162
// `proxy` lets you to specify a fallback server during development.
150163
// Every unrecognized request will be forwarded to it.
151164
const proxy = require(paths.appPackageJson).proxy;
165+
devServer.use(launchEditorMiddleware());
152166
devServer.use(
153167
historyApiFallback({
154168
// Paths with dots should still use the history fallback.

0 commit comments

Comments
 (0)