Skip to content

Commit a8b1811

Browse files
Copilotrajbos
andcommitted
Fix GitHub Pages deployment issues: add missing theme.css and simplify workflow
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent 36c8b6f commit a8b1811

3 files changed

Lines changed: 4 additions & 144 deletions

File tree

.github/workflows/deploy-to-pages.yml

Lines changed: 2 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -35,152 +35,11 @@ jobs:
3535
node-version: "18"
3636
cache: 'npm'
3737

38-
- name: Create simplified vite config
39-
run: |
40-
cat > vite.config.js << 'EOF'
41-
import { defineConfig } from "vite";
42-
import react from "@vitejs/plugin-react";
43-
import tailwindcss from "@tailwindcss/vite";
44-
import { resolve } from 'path';
45-
46-
// https://vitejs.dev/config/
47-
export default defineConfig({
48-
plugins: [react(), tailwindcss()],
49-
build: {
50-
base: "/github-copilot-usage/",
51-
outDir: 'dist'
52-
},
53-
resolve: {
54-
alias: {
55-
'@': resolve(__dirname, 'src')
56-
}
57-
}
58-
});
59-
EOF
60-
61-
- name: Create simplified package.json
62-
run: |
63-
cat > simplified-package.json << 'EOF'
64-
{
65-
"name": "github-copilot-usage-analyzer",
66-
"private": true,
67-
"version": "1.0.0",
68-
"type": "module",
69-
"scripts": {
70-
"build": "vite build",
71-
"preview": "vite preview"
72-
},
73-
"dependencies": {
74-
"@heroicons/react": "^2.2.0",
75-
"@phosphor-icons/react": "^2.1.7",
76-
"@radix-ui/colors": "^3.0.0",
77-
"@radix-ui/react-accordion": "^1.2.3",
78-
"@radix-ui/react-alert-dialog": "^1.1.6",
79-
"@radix-ui/react-aspect-ratio": "^1.1.2",
80-
"@radix-ui/react-avatar": "^1.1.3",
81-
"@radix-ui/react-checkbox": "^1.1.4",
82-
"@radix-ui/react-collapsible": "^1.1.3",
83-
"@radix-ui/react-context-menu": "^2.2.6",
84-
"@radix-ui/react-dialog": "^1.1.6",
85-
"@radix-ui/react-dropdown-menu": "^2.1.6",
86-
"@radix-ui/react-hover-card": "^1.1.6",
87-
"@radix-ui/react-label": "^2.1.2",
88-
"@radix-ui/react-menubar": "^1.1.6",
89-
"@radix-ui/react-navigation-menu": "^1.2.5",
90-
"@radix-ui/react-popover": "^1.1.6",
91-
"@radix-ui/react-progress": "^1.1.2",
92-
"@radix-ui/react-radio-group": "^1.2.3",
93-
"@radix-ui/react-scroll-area": "^1.2.9",
94-
"@radix-ui/react-select": "^2.1.6",
95-
"@radix-ui/react-separator": "^1.1.2",
96-
"@radix-ui/react-slider": "^1.2.3",
97-
"@radix-ui/react-slot": "^1.1.2",
98-
"@radix-ui/react-switch": "^1.1.3",
99-
"@radix-ui/react-tabs": "^1.1.3",
100-
"@radix-ui/react-toggle": "^1.1.2",
101-
"@radix-ui/react-toggle-group": "^1.1.2",
102-
"@radix-ui/react-tooltip": "^1.1.8",
103-
"class-variance-authority": "^0.7.1",
104-
"clsx": "^2.1.1",
105-
"cmdk": "^1.1.1",
106-
"d3": "^7.9.0",
107-
"date-fns": "^3.6.0",
108-
"embla-carousel-react": "^8.5.2",
109-
"framer-motion": "^12.6.2",
110-
"input-otp": "^1.4.2",
111-
"lucide-react": "^0.484.0",
112-
"marked": "^15.0.7",
113-
"react": "^19.0.0",
114-
"react-day-picker": "^9.6.7",
115-
"react-dom": "^19.0.0",
116-
"react-hook-form": "^7.54.2",
117-
"react-resizable-panels": "^2.1.7",
118-
"recharts": "^2.15.1",
119-
"sonner": "^2.0.1",
120-
"tailwind-merge": "^3.0.2",
121-
"three": "^0.175.0",
122-
"tw-animate-css": "^1.2.4",
123-
"uuid": "^11.1.0",
124-
"vaul": "^1.1.2",
125-
"zod": "^3.24.2"
126-
},
127-
"devDependencies": {
128-
"@tailwindcss/vite": "^4.0.17",
129-
"@types/react": "^19.0.10",
130-
"@types/react-dom": "^19.0.4",
131-
"@vitejs/plugin-react": "^4.3.4",
132-
"tailwindcss": "^4.0.17",
133-
"typescript": "~5.7.2",
134-
"vite": "^6.3.5"
135-
}
136-
}
137-
EOF
138-
mv simplified-package.json package.json
139-
14038
- name: Install dependencies
14139
run: npm install
14240

143-
- name: Create modified App with no Spark dependencies
144-
run: |
145-
# Create a file to replace @github/spark imports
146-
mkdir -p src/spark-shims
147-
cat > src/spark-shims/hooks.js << 'EOF'
148-
import { useState } from 'react';
149-
150-
// Simple localStorage-based shim for useKV hook
151-
export function useKV(key, initialValue) {
152-
const storageKey = `kv-${key}`;
153-
154-
// Get from localStorage
155-
const stored = localStorage.getItem(storageKey);
156-
const initial = stored !== null ? JSON.parse(stored) : initialValue;
157-
158-
const [value, setValue] = useState(initial);
159-
160-
const setValueAndStore = (newValue) => {
161-
const valueToStore = newValue instanceof Function ? newValue(value) : newValue;
162-
setValue(valueToStore);
163-
localStorage.setItem(storageKey, JSON.stringify(valueToStore));
164-
};
165-
166-
const deleteValue = () => {
167-
setValue(null);
168-
localStorage.removeItem(storageKey);
169-
};
170-
171-
return [value, setValueAndStore, deleteValue];
172-
}
173-
EOF
174-
175-
- name: Update imports in code
176-
run: |
177-
# Replace imports from @github/spark/hooks with our shim
178-
find src -type f -name "*.ts" -o -name "*.tsx" | xargs sed -i 's/import {.*} from "@github\/spark\/hooks"/import { useKV } from "..\/spark-shims\/hooks"/g'
179-
180-
- name: Use GitHub Pages main file
181-
run: |
182-
# Use the main-github-pages.tsx instead of main.tsx to avoid Spark imports
183-
cp src/main-github-pages.tsx src/main.tsx
41+
- name: Build for GitHub Pages
42+
run: npm run build:pages
18443

18544
- name: Setup Pages
18645
uses: actions/configure-pages@v4

build-for-gh-pages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
cp src/main-github-pages.tsx src/main.tsx
66

77
# Build using Vite with the GitHub Pages config
8-
vite build --config vite.github-pages.config.ts
8+
npx vite build --config vite.github-pages.config.ts
99

1010
# Restore the original main file if you need to continue local development
1111
git checkout src/main.tsx

src/main-github-pages.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import { createRoot } from 'react-dom/client'
33
import App from './App.tsx'
44
import "./main.css"
5+
import "./styles/theme.css"
56
import "./index.css"
67
// @github/spark/spark import is excluded and handled externally
78

0 commit comments

Comments
 (0)