mirror of https://github.com/buster-so/buster.git
Add ssr only for dev tools
This commit is contained in:
parent
47ee54dd58
commit
2c06dbc6de
|
@ -39,15 +39,17 @@ function shouldSuppressWarning(warning) {
|
|||
}
|
||||
|
||||
export default {
|
||||
sourcemap: false,
|
||||
rollupConfig: {
|
||||
onwarn(warning, defaultHandler) {
|
||||
if (shouldSuppressWarning(warning)) {
|
||||
return;
|
||||
}
|
||||
// rollupConfig: {
|
||||
// onwarn(warning, defaultHandler) {
|
||||
// if (shouldSuppressWarning(warning)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Handle all other warnings normally
|
||||
defaultHandler(warning);
|
||||
},
|
||||
},
|
||||
// // Handle all other warnings normally
|
||||
// defaultHandler(warning);
|
||||
// },
|
||||
// onerror: (id) => {
|
||||
// console.error(`Big nate: Error in ${id}`);
|
||||
// },
|
||||
// },
|
||||
};
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build -- --typecheck",
|
||||
"build:staging": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode staging",
|
||||
"build:production": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode production -- --typecheck",
|
||||
"build:local": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build -- --typecheck --local",
|
||||
"build:cloudflare": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192 --max-semi-space-size=256\" TYPECHECK=false vite build --mode production",
|
||||
"build:cf-optimized": "cross-env NODE_OPTIONS=\"--max-old-space-size=7680 --optimize-for-size\" TYPECHECK=false vite build --mode production",
|
||||
"build:local": "cross-env NODE_OPTIONS=--max-old-space-size=12288 vite build -- --typecheck --local",
|
||||
"build-storybook": "storybook build",
|
||||
"build:visualize": "npx vite-bundle-visualizer",
|
||||
"deploy:dev": "pnpm run build && npx wrangler deploy .output/server/index.mjs --env dev --assets .output/public",
|
||||
|
@ -26,7 +28,7 @@
|
|||
"test:ui": "vitest --ui",
|
||||
"test:unit": "pnpm run test",
|
||||
"test:watch": "vitest --watch",
|
||||
"typecheck": "cross-env NODE_OPTIONS=--max-old-space-size=8192 tsc --noEmit",
|
||||
"typecheck": "cross-env NODE_OPTIONS=--max-old-space-size=12288 tsc --noEmit",
|
||||
"typecheck:watch": "tsc --noEmit --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { ClientOnly } from '@tanstack/react-router';
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
import { useMount } from '@/hooks/useMount';
|
||||
import { isServer } from '@/lib/window';
|
||||
|
||||
// Only create lazy components if we're in the browser
|
||||
|
@ -37,12 +38,14 @@ const LazyMetricStoreDevtools = !import.meta.env.SSR
|
|||
|
||||
// The actual devtools component implementation
|
||||
const TanstackDevtoolsImpl: React.FC = React.memo(() => {
|
||||
if (import.meta.env.SSR || isServer) {
|
||||
console.log('Is SSR or Server');
|
||||
return null;
|
||||
} // never render on SSR
|
||||
useMount(() => {
|
||||
console.log('🐓 Rendering TanstackDevtoolsImpl');
|
||||
});
|
||||
const isServerOrSSR = isServer && import.meta.env.SSR;
|
||||
|
||||
console.log('🐓 Rendering TanstackDevtoolsImpl');
|
||||
if (isServerOrSSR) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ClientOnly>
|
||||
|
|
|
@ -7,7 +7,7 @@ import viteTsConfigPaths from 'vite-tsconfig-paths';
|
|||
|
||||
const config = defineConfig(({ command, mode }) => {
|
||||
const isBuild = command === 'build';
|
||||
const isProduction = mode === 'production';
|
||||
const isProduction = mode === 'production' || mode === 'staging';
|
||||
const isTypecheck = process.argv.includes('--typecheck') || process.env.TYPECHECK === 'true';
|
||||
const useChecker = !process.env.VITEST && isBuild;
|
||||
const isLocalBuild = process.argv.includes('--local');
|
||||
|
@ -34,7 +34,9 @@ const config = defineConfig(({ command, mode }) => {
|
|||
format: 'es',
|
||||
},
|
||||
build: {
|
||||
chunkSizeWarningLimit: 850,
|
||||
chunkSizeWarningLimit: 1250,
|
||||
minify: isProduction ? 'esbuild' : false,
|
||||
reportCompressedSize: false, // Disable gzip size reporting to speed up build
|
||||
rollupOptions: {
|
||||
// Exclude test and stories files from build
|
||||
external: (id) => {
|
||||
|
@ -66,6 +68,12 @@ const config = defineConfig(({ command, mode }) => {
|
|||
}
|
||||
},
|
||||
},
|
||||
// Optimize tree-shaking for CloudFlare
|
||||
treeshake: {
|
||||
moduleSideEffects: false,
|
||||
propertyReadSideEffects: false,
|
||||
tryCatchDeoptimization: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue