Skip to content

Commit

Permalink
perf: minify html; inject css to index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Sep 28, 2024
1 parent a9b3e0a commit 3e8e38f
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 29 deletions.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
);
</script>

<!-- Inject main styles to index.html -->
<style>
@import "/src/app/styles.css";
</style>

<!-- The app entrypoint -->
<script type="module" src="/src/app/entry-client.tsx"></script>
</head>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"typescript-eslint": "^8.7.0",
"usehooks-ts": "^3.1.0",
"vite": "^5.4.7",
"vite-plugin-minify": "^2.0.0",
"vite-plugin-pwa": "^0.20.5",
"vite-tsconfig-paths": "^5.0.1",
"workbox-window": "^7.1.0",
Expand Down
107 changes: 107 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 0 additions & 2 deletions src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "./styles.css";

import { queryClient } from "@/app/query-client.ts";
import { AuthManager } from "@/lib/auth/AuthManager.tsx";
import { useMe } from "@/lib/auth/user.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/MoodleUrlPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export declare type MoodleUrlPreviewProps = {
export default function MoodleUrlPreview({ source }: MoodleUrlPreviewProps) {
return (
<>
<div className="custom-preview-scrollbar flex h-[400px] w-full items-center justify-center overflow-hidden rounded-2xl shadow-lg">
<div className="flex h-[400px] w-full items-center justify-center overflow-hidden rounded-2xl shadow-lg">
<a
href={source.url}
className="flex flex-row items-center justify-center gap-2 hover:text-secondary-hover"
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/PdfPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function PdfPreview({ source, searchText }: PdfPreviewProps) {
>
{pdfDocument !== null && (
<div className="flex items-center justify-center">
<div className="custom-preview-scrollbar overflow-hidden rounded-2xl shadow-lg">
<div className="overflow-hidden rounded-2xl shadow-lg">
<Page
noData={
<div
Expand Down
1 change: 0 additions & 1 deletion src/components/search/SearchField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import "./search.css";

export default function SearchField({
runSearch,
Expand Down
7 changes: 1 addition & 6 deletions src/components/search/TelegramPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,5 @@ export default function TelegramPreview({ source }: TelegramPreviewProps) {
};
}, [isDarkMode, source.link]);

return (
<div
ref={ref}
className="custom-preview-scrollbar overflow-auto rounded-lg shadow-lg"
/>
);
return <div ref={ref} className="overflow-auto rounded-lg shadow-lg" />;
}
18 changes: 0 additions & 18 deletions src/components/search/search.css

This file was deleted.

4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import viteReact from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { ViteMinifyPlugin } from "vite-plugin-minify";
import { VitePWA } from "vite-plugin-pwa";
import tsconfigPaths from "vite-tsconfig-paths";
import { version } from "./package.json";
Expand Down Expand Up @@ -32,6 +33,9 @@ export default defineConfig({
},
manifest: false, // Manifest is already in public/manifest.json
}),

// Minify the index.html
ViteMinifyPlugin({}),
],

define: {
Expand Down

0 comments on commit 3e8e38f

Please sign in to comment.