kopia lustrzana https://github.com/cheeaun/phanpy
Exclude sandbox from prod
rodzic
493a68d5b6
commit
18d2f0bdf6
20
src/app.jsx
20
src/app.jsx
|
@ -2,7 +2,7 @@ import './app.css';
|
|||
|
||||
import { useLingui } from '@lingui/react';
|
||||
import debounce from 'just-debounce-it';
|
||||
import { memo } from 'preact/compat';
|
||||
import { lazy, memo, Suspense } from 'preact/compat';
|
||||
import {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
|
@ -43,7 +43,6 @@ import Login from './pages/login';
|
|||
import Mentions from './pages/mentions';
|
||||
import Notifications from './pages/notifications';
|
||||
import Public from './pages/public';
|
||||
import Sandbox from './pages/sandbox';
|
||||
import ScheduledPosts from './pages/scheduled-posts';
|
||||
import Search from './pages/search';
|
||||
import StatusRoute from './pages/status-route';
|
||||
|
@ -70,6 +69,12 @@ import {
|
|||
|
||||
import './utils/toast-alert';
|
||||
|
||||
// Lazy load Sandbox component only in development
|
||||
const Sandbox =
|
||||
import.meta.env.DEV || import.meta.env.PHANPY_DEV
|
||||
? lazy(() => import('./pages/sandbox'))
|
||||
: () => null;
|
||||
|
||||
window.__STATES__ = states;
|
||||
window.__STATES_STATS__ = () => {
|
||||
const keys = [
|
||||
|
@ -506,7 +511,16 @@ const PrimaryRoutes = memo(({ isLoggedIn }) => {
|
|||
<Route path="/" element={<Root isLoggedIn={isLoggedIn} />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/welcome" element={<Welcome />} />
|
||||
<Route path="/_sandbox" element={<Sandbox />} />
|
||||
{(import.meta.env.DEV || import.meta.env.PHANPY_DEV) && (
|
||||
<Route
|
||||
path="/_sandbox"
|
||||
element={
|
||||
<Suspense fallback={<Loader id="loader-sandbox" />}>
|
||||
<Sandbox />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Routes>
|
||||
);
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ const {
|
|||
PHANPY_CLIENT_NAME: CLIENT_NAME,
|
||||
PHANPY_APP_ERROR_LOGGING: ERROR_LOGGING,
|
||||
PHANPY_REFERRER_POLICY: REFERRER_POLICY,
|
||||
PHANPY_DEV,
|
||||
} = loadEnv('production', process.cwd(), allowedEnvPrefixes);
|
||||
|
||||
const now = new Date();
|
||||
|
@ -190,7 +191,28 @@ export default defineConfig({
|
|||
}
|
||||
return 'assets/[name]-[hash].js';
|
||||
},
|
||||
assetFileNames: (assetInfo) => {
|
||||
const { originalFileNames } = assetInfo;
|
||||
if (originalFileNames?.[0]?.includes('assets/sandbox')) {
|
||||
return 'assets/sandbox/[name]-[hash].[ext]';
|
||||
}
|
||||
return 'assets/[name]-[hash].[ext]';
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
name: 'exclude-sandbox',
|
||||
generateBundle(_, bundle) {
|
||||
if (!PHANPY_DEV) {
|
||||
Object.entries(bundle).forEach(([name, chunk]) => {
|
||||
if (name.includes('sandbox')) {
|
||||
delete bundle[name];
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue