Skip to content

Commit 826e5fc

Browse files
committed
fix: MIME type with gihtub page
1 parent 2ee5c91 commit 826e5fc

File tree

2 files changed

+26
-68
lines changed

2 files changed

+26
-68
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,79 +40,39 @@ jobs:
4040
VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}
4141
# Disable public registration for production
4242
VITE_ENABLE_PUBLIC_REGISTRATION: 'false'
43-
# Set base path for GitHub Pages (root for TradingGoose.github.io)
44-
PUBLIC_URL: /
4543
# Set to production to enable console stripping
4644
NODE_ENV: production
4745
run: npm run build
4846

4947
- name: Copy index.html to 404.html for SPA routing
5048
run: cp ./dist/index.html ./dist/404.html
5149

52-
- name: Add .nojekyll file
53-
run: touch ./dist/.nojekyll
54-
55-
- name: Fix GitHub Pages compatibility and create _headers
50+
- name: Prepare for GitHub Pages
5651
run: |
57-
cd ./dist
58-
59-
# Create proper Netlify-style _headers file for GitHub Pages compatibility
60-
cat > _headers << 'EOF'
61-
/*
62-
X-Frame-Options: DENY
63-
X-Content-Type-Options: nosniff
64-
Referrer-Policy: strict-origin-when-cross-origin
65-
66-
/*.js
67-
Content-Type: text/javascript; charset=utf-8
68-
Cache-Control: public, max-age=31536000, immutable
69-
70-
/*.mjs
71-
Content-Type: text/javascript; charset=utf-8
72-
Cache-Control: public, max-age=31536000, immutable
52+
# Add .nojekyll to prevent Jekyll processing
53+
touch ./dist/.nojekyll
7354
74-
/assets/*.js
75-
Content-Type: text/javascript; charset=utf-8
76-
Cache-Control: public, max-age=31536000, immutable
55+
# Add CNAME file if using custom domain (comment out if not needed)
56+
# echo "yourdomain.com" > ./dist/CNAME
7757
78-
/*.css
79-
Content-Type: text/css; charset=utf-8
80-
Cache-Control: public, max-age=31536000, immutable
58+
# Verify the build output
59+
echo "=== Build Output Structure ==="
60+
ls -la ./dist/
8161
82-
/assets/*.css
83-
Content-Type: text/css; charset=utf-8
84-
Cache-Control: public, max-age=31536000, immutable
85-
86-
/favicon.ico
87-
Content-Type: image/x-icon
88-
Cache-Control: public, max-age=86400
89-
EOF
90-
91-
# Verify files exist
92-
echo "=== Checking build output ==="
93-
ls -la ./
94-
echo ""
95-
echo "=== Assets directory ==="
96-
ls -la assets/ || echo "No assets directory found"
9762
echo ""
63+
echo "=== JavaScript Files ==="
64+
find ./dist -name "*.js" -type f | head -10
9865
99-
# Find all JavaScript files
100-
find . -name "*.js" -type f | while read file; do
101-
echo "✓ Found JS file: $file ($(file -b --mime-type "$file"))"
102-
done
103-
104-
# Verify favicon
105-
if [ ! -f "favicon.ico" ]; then
106-
echo "ERROR: favicon.ico not found"
107-
exit 1
66+
echo ""
67+
echo "=== Checking index.html ==="
68+
if [ -f "./dist/index.html" ]; then
69+
echo "✓ index.html found"
70+
# Show script tags to debug MIME type issues
71+
grep -E '<script|<link' ./dist/index.html | head -5
10872
else
109-
echo "✓ favicon.ico found ($(file -b --mime-type favicon.ico))"
73+
echo "ERROR: index.html not found!"
74+
exit 1
11075
fi
111-
112-
# Check HTML references
113-
echo ""
114-
echo "=== Module script references in HTML ==="
115-
grep 'type="module"' index.html || echo "No module scripts found"
11676
11777
- name: Setup Pages
11878
uses: actions/configure-pages@v4

vite.config.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,22 @@ export default defineConfig(({ mode }) => ({
3636
target: 'es2015',
3737
modulePreload: {
3838
polyfill: true,
39-
resolveDependencies: (_, deps) => deps
4039
},
4140
rollupOptions: {
4241
output: {
4342
// Ensure JS files have proper extensions and format for GitHub Pages
4443
format: 'es',
45-
entryFileNames: 'assets/main.[hash].js',
46-
chunkFileNames: 'assets/chunk.[hash].js',
44+
entryFileNames: '[name]-[hash].js',
45+
chunkFileNames: 'chunks/[name]-[hash].js',
4746
assetFileNames: (assetInfo) => {
48-
// Use simple, clear naming for GitHub Pages compatibility
49-
const fileName = assetInfo.names?.[0] || 'asset';
50-
if (fileName.endsWith('.css')) {
51-
return 'assets/styles.[hash].css';
47+
const info = assetInfo.names?.[0] || '';
48+
if (/\.(css)$/.test(info)) {
49+
return 'css/[name]-[hash][extname]';
5250
}
53-
if (fileName.endsWith('.png') || fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.gif') || fileName.endsWith('.svg')) {
54-
return 'assets/images/[name].[hash][extname]';
51+
if (/\.(png|jpg|jpeg|gif|svg|ico|webp)$/.test(info)) {
52+
return 'images/[name]-[hash][extname]';
5553
}
56-
return 'assets/[name].[hash][extname]';
54+
return 'assets/[name]-[hash][extname]';
5755
},
5856
manualChunks: undefined
5957
}

0 commit comments

Comments
 (0)