setup webserver for flipper-server
Summary: This sets up the metro bundler for flipper-server, to be able to serve the front end. Note that this is a setup that is only relevant for development purposes Done in this diff: * setup metro * setup fast refresh * setup nodemon to be able to refresh on server changes Not done in this diff * Setup FlipperServerImpl in the flipper-server * Load flipper-ui-core in flipper-ui-browser * Load plugins * Support options, env vars etc etc * Make flipper-server stand alone (it is largely self contained, but still requires some static resources like theming) Reviewed By: passy, aigoncharov Differential Revision: D32626137 fbshipit-source-id: 47f580356ddf0993392d3b583082b187661727e9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2b81be6c29
commit
0dfc73da93
53
desktop/flipper-ui-browser/src/index-fast-refresh.tsx
Normal file
53
desktop/flipper-ui-browser/src/index-fast-refresh.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {default as HmrClient} from './HMRClient';
|
||||
// @ts-ignore
|
||||
import {default as ReactRefreshRuntime} from 'react-refresh/runtime';
|
||||
|
||||
HmrClient.setup(
|
||||
'web',
|
||||
(window as any).flipperConfig.entryPoint,
|
||||
'localhost',
|
||||
window.location.port,
|
||||
true,
|
||||
);
|
||||
|
||||
ReactRefreshRuntime.injectIntoGlobalHook(window);
|
||||
|
||||
const Refresh = {
|
||||
performFullRefresh(reason: string) {
|
||||
console.log('Perform full refresh', reason);
|
||||
window.location.reload();
|
||||
},
|
||||
|
||||
createSignatureFunctionForTransform:
|
||||
ReactRefreshRuntime.createSignatureFunctionForTransform,
|
||||
|
||||
isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType,
|
||||
|
||||
getFamilyByType: ReactRefreshRuntime.getFamilyByType,
|
||||
|
||||
register: ReactRefreshRuntime.register,
|
||||
|
||||
performReactRefresh() {
|
||||
if (ReactRefreshRuntime.hasUnrecoverableErrors()) {
|
||||
console.error('Fast refresh - Unrecolverable');
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
ReactRefreshRuntime.performReactRefresh();
|
||||
console.log('Perform react refresh');
|
||||
},
|
||||
};
|
||||
|
||||
(require as any).Refresh = Refresh;
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
require('./index.tsx');
|
||||
Reference in New Issue
Block a user