Découpage du code et extraction des sourcemaps
This commit is contained in:
parent
85008d3265
commit
f752865d33
|
@ -1,10 +1,5 @@
|
|||
import React, { FunctionComponent, useState, useEffect } from 'react';
|
||||
import React, { FunctionComponent, useState, useEffect, Suspense } from 'react';
|
||||
import { BrowserRouter, Route, Redirect, Switch } from "react-router-dom";
|
||||
import { HomePage } from './HomePage/HomePage';
|
||||
import { ProfilePage } from './ProfilePage/ProfilePage';
|
||||
import { WorkgroupPage } from './WorkgroupPage/WorkgroupPage';
|
||||
import { DecisionSupportFilePage } from './DecisionSupportFilePage/DecisionSupportFilePage';
|
||||
import { DashboardPage } from './DashboardPage/DashboardPage';
|
||||
import { useUserProfile } from '../gql/queries/profile';
|
||||
import { LoggedInContext, getSavedLoggedIn, saveLoggedIn } from '../hooks/useLoggedIn';
|
||||
import { PrivateRoute } from './PrivateRoute';
|
||||
|
@ -12,16 +7,21 @@ import { useKonamiCode } from '../hooks/useKonamiCode';
|
|||
import { Modal } from './Modal';
|
||||
import { createClient } from '../util/apollo';
|
||||
import { ApolloProvider } from '@apollo/client';
|
||||
import { LogoutPage } from './LogoutPage';
|
||||
import { UnauthorizedPage } from './UnauthorizedPage/UnauthorizedPage';
|
||||
import { ConferencePage } from './ConferencePage/ConferencePage';
|
||||
import { AppLoader } from './AppLoader';
|
||||
|
||||
const LazyHomePage = React.lazy(() => import('./HomePage/HomePage'));
|
||||
const LazyDashboardPage = React.lazy(() => import('./DashboardPage/DashboardPage'));
|
||||
const LazyUnauthorizedPage = React.lazy(() => import('./UnauthorizedPage/UnauthorizedPage'));
|
||||
const LazyConferencePage = React.lazy(() => import('./ConferencePage/ConferencePage'));
|
||||
const LazyDecisionSupportFilePage = React.lazy(() => import('./DecisionSupportFilePage/DecisionSupportFilePage'));
|
||||
const LazyProfilePage = React.lazy(() => import('./ProfilePage/ProfilePage'));
|
||||
const LazyWorkgroupPage = React.lazy(() => import('./WorkgroupPage/WorkgroupPage'));
|
||||
const LazyLogoutPage = React.lazy(() => import('./LogoutPage'));
|
||||
|
||||
export interface AppProps {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const App: FunctionComponent<AppProps> = () => {
|
||||
const [ loggedIn, setLoggedIn ] = useState(getSavedLoggedIn());
|
||||
|
||||
|
@ -37,19 +37,20 @@ export const App: FunctionComponent<AppProps> = () => {
|
|||
useKonamiCode(() => setShowBoneyM(true));
|
||||
|
||||
return (
|
||||
<Suspense fallback={<AppLoader />}>
|
||||
<ApolloProvider client={client}>
|
||||
<LoggedInContext.Provider value={loggedIn}>
|
||||
<UserSessionCheck setLoggedIn={setLoggedIn} />
|
||||
<BrowserRouter>
|
||||
<Switch>
|
||||
<Route path="/" exact component={HomePage} />
|
||||
<Route path="/unauthorized" exact component={UnauthorizedPage} />
|
||||
<PrivateRoute path="/profile" exact component={ProfilePage} />
|
||||
<PrivateRoute path="/conference" exact component={ConferencePage} />
|
||||
<PrivateRoute path="/workgroups/:id" exact component={WorkgroupPage} />
|
||||
<PrivateRoute path="/decisions/:id" component={DecisionSupportFilePage} />
|
||||
<PrivateRoute path="/dashboard" exact component={DashboardPage} />
|
||||
<PrivateRoute path="/logout" exact component={LogoutPage} />
|
||||
<Route path="/" exact component={LazyHomePage} />
|
||||
<Route path="/unauthorized" exact component={LazyUnauthorizedPage} />
|
||||
<PrivateRoute path="/profile" exact component={LazyProfilePage} />
|
||||
<PrivateRoute path="/conference" exact component={LazyConferencePage} />
|
||||
<PrivateRoute path="/workgroups/:id" exact component={LazyWorkgroupPage} />
|
||||
<PrivateRoute path="/decisions/:id" component={LazyDecisionSupportFilePage} />
|
||||
<PrivateRoute path="/dashboard" exact component={LazyDashboardPage} />
|
||||
<PrivateRoute path="/logout" exact component={LazyLogoutPage} />
|
||||
<Route component={() => <Redirect to="/" />} />
|
||||
</Switch>
|
||||
</BrowserRouter>
|
||||
|
@ -66,6 +67,7 @@ export const App: FunctionComponent<AppProps> = () => {
|
|||
}
|
||||
</LoggedInContext.Provider>
|
||||
</ApolloProvider>
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import React, { FunctionComponent } from "react";
|
||||
|
||||
export const AppLoader:FunctionComponent = () => {
|
||||
return (
|
||||
<div className="loader"></div>
|
||||
)
|
||||
}
|
|
@ -110,6 +110,8 @@ export const ConferencePage:FunctionComponent<ConferencePageProps> = () => {
|
|||
);
|
||||
}
|
||||
|
||||
export default ConferencePage;
|
||||
|
||||
export interface UserCardProps {
|
||||
nickname: string
|
||||
email: string
|
||||
|
|
|
@ -13,3 +13,5 @@ export function DashboardPage() {
|
|||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default DashboardPage;
|
|
@ -160,3 +160,5 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
|||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
export default DecisionSupportFilePage;
|
|
@ -19,3 +19,5 @@ export function HomePage() {
|
|||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default HomePage;
|
|
@ -13,3 +13,5 @@ export const LogoutPage: FunctionComponent<LogoutPageProps> = () => {
|
|||
}, []);
|
||||
return null;
|
||||
};
|
||||
|
||||
export default LogoutPage;
|
|
@ -40,3 +40,5 @@ export function ProfilePage() {
|
|||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProfilePage;
|
|
@ -35,3 +35,5 @@ export const UnauthorizedPage:FunctionComponent<UnauthorizedPageProps> = () => {
|
|||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default UnauthorizedPage;
|
|
@ -151,3 +151,5 @@ export function WorkgroupPage() {
|
|||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default WorkgroupPage;
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "es6",
|
||||
"module": "es2020",
|
||||
"lib": ["dom", "es6"],
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
|
|
|
@ -11,7 +11,7 @@ const env = process.env;
|
|||
module.exports = {
|
||||
mode: `${env.NODE_ENV ? env.NODE_ENV : 'production'}`,
|
||||
entry: './src/index.tsx',
|
||||
devtool: 'inline-source-map',
|
||||
devtool: env.NODE_ENV === 'production' ? 'source-map' : 'eval-source-map',
|
||||
output: {
|
||||
filename: '[name].[contenthash].js',
|
||||
path: path.join(__dirname, 'dist')
|
||||
|
|
Loading…
Reference in New Issue