Mor*_*ani 10 reactjs webpack server-side-rendering
在生产中,react_devtools_backend.js 无论如何都会加载,这会减慢我的网站在生产中的速度。如何禁用加载此反应开发工具?我正在使用react 16.8、reactSSR、webpack 4.29、apollo
我已经用过
new webpack.DefinePlugin({
'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
}),
Run Code Online (Sandbox Code Playgroud)
和
if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === "object") {
for (let [key, value] of Object.entries(window.__REACT_DEVTOOLS_GLOBAL_HOOK__)) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__[key] = typeof value == "function" ? ()=>{} : null;
}
}
Run Code Online (Sandbox Code Playgroud)
和
<script>
if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
}
</script>
Run Code Online (Sandbox Code Playgroud)
和这个
const disableReactDevTools = (): void => {
const noop = (): void => undefined;
const DEV_TOOLS = (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__;
if (typeof DEV_TOOLS === 'object') {
for (const [key, value] of Object.entries(DEV_TOOLS)) {
DEV_TOOLS[key] = typeof value === 'function' ? noop : null;
}
}
};
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
9115 次 |
| 最近记录: |