Fixed standalone target not properly serving backend over localhost:8097

This commit is contained in:
Brian Vaughn
2019-08-19 07:36:41 -07:00
parent 14c2eab7c3
commit d2456c7572
2 changed files with 8 additions and 9 deletions
+2 -9
View File
@@ -12,7 +12,7 @@ import Store from 'src/devtools/store';
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
import { Server } from 'ws';
import { join } from 'path';
import { existsSync, readFileSync } from 'fs';
import { readFileSync } from 'fs';
import { installHook } from 'src/hook';
import DevTools from 'src/devtools/views/DevTools';
import { doesFilePathExist, launchEditor } from './editor';
@@ -257,15 +257,8 @@ function startServer(port?: number = 8097) {
});
httpServer.on('request', (request, response) => {
// NPM installs should read from node_modules,
// But local dev mode needs to use a relative path.
let basePath = join(__dirname, 'node_modules/react-devtools-core');
if (!existsSync(basePath)) {
basePath = '../react-devtools-core';
}
// Serve a file that immediately sets up the connection.
const backendFile = readFileSync(`${basePath}/dist/backend.js`);
const backendFile = readFileSync(join(__dirname, 'backend.js'));
// The renderer interface doesn't read saved component filters directly,
// because they are generally stored in localStorage within the context of the extension.
@@ -31,6 +31,12 @@ module.exports = {
src: resolve(__dirname, '../../src'),
},
},
node: {
// Don't replace __dirname!
// This would break the standalone DevTools ability to load the backend.
// see https://github.com/facebook/react-devtools/issues/1269
__dirname: false,
},
plugins: [
new DefinePlugin({
__DEV__: false,