mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed standalone target not properly serving backend over localhost:8097
This commit is contained in:
+2
-9
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user