diff --git a/.github/lighthouse/lighthouserc.json b/.github/lighthouse/lighthouserc.json new file mode 100644 index 0000000..10ba861 --- /dev/null +++ b/.github/lighthouse/lighthouserc.json @@ -0,0 +1,67 @@ +{ + "ci": { + "collect": { + "startServerCommand": "npm run preview", + "url": [ + "http://localhost:4173/" + ], + "numberOfRuns": 3 + }, + "assert": { + "preset": "lighthouse:recommended", + "assertions": { + "categories:performance": [ + "error", + { + "minScore": 0.9 + } + ], + "categories:accessibility": [ + "warn", + { + "minScore": 0.9 + } + ], + "categories:best-practices": [ + "warn", + { + "minScore": 0.9 + } + ], + "categories:seo": [ + "warn", + { + "minScore": 0.9 + } + ], + "first-contentful-paint": [ + "warn", + { + "maxNumericValue": 2000 + } + ], + "largest-contentful-paint": [ + "error", + { + "maxNumericValue": 2500 + } + ], + "cumulative-layout-shift": [ + "error", + { + "maxNumericValue": 0.1 + } + ], + "total-blocking-time": [ + "warn", + { + "maxNumericValue": 200 + } + ] + } + }, + "upload": { + "target": "temporary-public-storage" + } + } +} \ No newline at end of file diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml new file mode 100644 index 0000000..be9f69e --- /dev/null +++ b/.github/workflows/lighthouse-ci.yml @@ -0,0 +1,32 @@ +name: Lighthouse CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lighthouse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Run Lighthouse CI + uses: treosh/lighthouse-ci-action@v11 + with: + uploadArtifacts: true + temporaryPublicStorage: true + configPath: ./.github/lighthouse/lighthouserc.json diff --git a/App.tsx b/App.tsx index cc16c89..3d6653c 100644 --- a/App.tsx +++ b/App.tsx @@ -5,10 +5,12 @@ import { Navbar } from './components/Navbar'; import { Footer } from './components/Footer'; import { ErrorBoundary } from './components/ErrorBoundary'; import { AuthProvider } from './components/AuthProvider'; -// Halaman yang dimuat secara eager +// Halaman yang dimuat secara eager (Cuma Home buat LCP) import { Home } from './pages/Home'; -import { Login } from './pages/Auth/Login'; -import { Register } from './pages/Auth/Register'; + +// Halaman yang dimuat secara lazy (biar enteng pas buka awal) +const Login = React.lazy(() => import('./pages/Auth/Login').then(module => ({ default: module.Login }))); +const Register = React.lazy(() => import('./pages/Auth/Register').then(module => ({ default: module.Register }))); // Halaman yang dimuat secara lazy (biar enteng pas buka awal) const Karya = React.lazy(() => import('./pages/Karya')); @@ -137,13 +139,13 @@ const AppContent = () => { return (
{ e.currentTarget.style.display = 'none'; }} />
+