mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(profiling): add react-scan via direct import for dev-only profiling
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import './polyfills.js';
|
import './polyfills.js';
|
||||||
|
import './lib/react-scan';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import App from './app';
|
import App from './app';
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
if (import.meta.env.DEV) {
|
||||||
|
const { scan, getReport } = await import('react-scan');
|
||||||
|
scan({
|
||||||
|
enabled: true,
|
||||||
|
showToolbar: !(window as any).__PROFILING__,
|
||||||
|
playSound: !(window as any).__PROFILING__,
|
||||||
|
report: true,
|
||||||
|
});
|
||||||
|
(window as any).__getReactScanReport = getReport;
|
||||||
|
}
|
||||||
@@ -3,10 +3,6 @@ import react from '@vitejs/plugin-react';
|
|||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||||
import { VitePWA } from 'vite-plugin-pwa';
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
import reactScan from '@react-scan/vite-plugin-react-scan';
|
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
|
||||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -22,12 +18,6 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// Only include React Scan in development mode - never in production builds
|
|
||||||
(isDevelopment || (!isProduction && process.env.NODE_ENV !== 'production')) &&
|
|
||||||
reactScan({
|
|
||||||
showToolbar: true,
|
|
||||||
playSound: true,
|
|
||||||
}),
|
|
||||||
nodePolyfills({
|
nodePolyfills({
|
||||||
globals: {
|
globals: {
|
||||||
Buffer: true,
|
Buffer: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user