Skip to content

Commit

Permalink
perf: speed up init cold start load.
Browse files Browse the repository at this point in the history
remove unused deps.
add vite rollup options to split chunks.
replace global loader with sira loader.
  • Loading branch information
riccox committed Mar 6, 2023
1 parent 06b0f2d commit a78086c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 125 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
"@mantine/hooks": "^6.0.0",
"@mantine/modals": "^6.0.0",
"@mantine/notifications": "^6.0.0",
"@mantine/nprogress": "^6.0.0",
"@sira-ui/tailwind": "^0.6.1",
"@sira-ui/tailwind": "^0.7.0",
"@tabler/icons-react": "^2.7.0",
"@uiball/loaders": "^1.2.6",
"ahooks": "^3.7.5",
"dayjs": "^1.11.7",
"echarts": "^5.4.1",
Expand All @@ -36,7 +34,6 @@
"meilisearch": "^0.31.1",
"qs": "^6.11.0",
"react": "^18.2.0",
"react-animated-numbers": "^0.16.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4",
"react-json-view": "^1.21.3",
Expand Down
116 changes: 4 additions & 112 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/components/Loader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { FC } from 'react';

import { JellyTriangle } from '@uiball/loaders';
import { useMantineTheme } from '@mantine/core';

interface Props {
size?: number;
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
}

export const Loader: FC<Props> = ({ size }) => {
const theme = useMantineTheme();
return <JellyTriangle size={size ?? 60} speed={2} color={theme.colors.brand[5]} />;
export const Loader: FC<Props> = ({ size = 'md' }) => {
return (
<div className={`${size} loader primary`}>
<div className="bar-bounce" />
</div>
);
};
2 changes: 1 addition & 1 deletion src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const AppRoutes = () => {
<Suspense
fallback={
<div className={`flex full-page justify-center items-center`}>
<Loader size={120} />
<Loader size={'xl'} />
</div>
}
>
Expand Down
14 changes: 14 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,18 @@ export default defineConfig({
host: true,
port: 24900,
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
// node_modules is mostly the main reason for the large chunk problem,
// With this you're telling Vite to treat the used modules separately.
// To understand better what it does, try to compare the logs from the build command with and without this change.
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
},
},
},
});

1 comment on commit a78086c

@vercel
Copy link

@vercel vercel bot commented on a78086c Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.