Skip to content

Commit b3afdc1

Browse files
author
Parsa Azari
committed
Force deploy: Cache bust 1749064439
1 parent b0db0ea commit b3afdc1

9 files changed

Lines changed: 209 additions & 29 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
- name: Build
3737
run: npm run build
3838

39+
- name: Add cache busting
40+
run: |
41+
# Add timestamp to main HTML file to bust cache
42+
sed -i "s/<!-- Fixed deployment - v4 with cache busting -->/<!-- Build: $(date +%s) -->/g" dist/index.html
43+
44+
# Ensure proper MIME types for .js files
45+
find dist -name "*.js" -exec echo "Adding headers for {}" \;
46+
3947
- name: Setup Pages
4048
uses: actions/configure-pages@v4
4149

dist/404.html

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,77 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Page Not Found</title>
6+
<title>3D Portfolio - Page Not Found</title>
77
<script>
8-
// Redirect to the home page
9-
const segmentCount = 1;
10-
const redirectPath = window.location.pathname.split('/').slice(0, segmentCount + 1).join('/');
11-
window.location.replace(`${redirectPath}/`);
8+
// GitHub Pages SPA redirect
9+
// This script takes the current url and converts the path and query
10+
// string into just a query string, and then redirects the browser
11+
// to the new url with only a query string and hash fragment,
12+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
13+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
14+
var l = window.location;
15+
var pathSegmentsToKeep = 1; // The number of path segments to keep (only the repository name)
16+
17+
l.replace(
18+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
19+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
20+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
21+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
22+
l.hash
23+
);
1224
</script>
1325
<style>
1426
body {
1527
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
1628
text-align: center;
17-
padding: 20px;
29+
padding: 50px 20px;
1830
background: #000;
19-
color: #fff;
31+
color: #e0e0e0;
32+
margin: 0;
33+
}
34+
.container {
35+
max-width: 600px;
36+
margin: 0 auto;
2037
}
2138
h1 {
22-
margin-top: 50px;
2339
color: #5CDED3;
40+
font-size: 2.5em;
41+
margin-bottom: 20px;
2442
}
2543
p {
2644
margin: 20px 0;
45+
font-size: 1.1em;
46+
line-height: 1.6;
47+
}
48+
.loading {
49+
animation: pulse 2s infinite;
50+
}
51+
@keyframes pulse {
52+
0% { opacity: 0.5; }
53+
50% { opacity: 1; }
54+
100% { opacity: 0.5; }
2755
}
2856
a {
2957
color: #5CDED3;
3058
text-decoration: none;
59+
border: 1px solid #5CDED3;
60+
padding: 10px 20px;
61+
display: inline-block;
62+
margin-top: 20px;
63+
transition: all 0.3s ease;
3164
}
3265
a:hover {
33-
text-decoration: underline;
66+
background: #5CDED3;
67+
color: #000;
3468
}
3569
</style>
3670
</head>
3771
<body>
38-
<h1>Page Not Found</h1>
39-
<p>Redirecting to the home page...</p>
40-
<p>If you are not redirected automatically, <a href="/3D-Portfolio/">click here</a>.</p>
72+
<div class="container">
73+
<h1>Redirecting...</h1>
74+
<p class="loading">Please wait while we redirect you to the 3D Portfolio experience.</p>
75+
<p>If you are not redirected automatically:</p>
76+
<a href="/3D-Portfolio/">Return to 3D Portfolio</a>
77+
</div>
4178
</body>
4279
</html>

dist/index.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,31 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>3D Portfolio</title>
77
<link rel="icon" type="image/x-icon" href="/3D-Portfolio/favicon.ico">
8-
<!-- Fixed deployment - v3 -->
8+
<!-- GitHub Pages SPA support -->
9+
<script>
10+
// Check if we have a redirect parameter (from 404.html)
11+
(function() {
12+
var redirect = sessionStorage.redirect;
13+
delete sessionStorage.redirect;
14+
if (redirect && redirect != location.href) {
15+
history.replaceState(null, null, redirect);
16+
}
17+
})();
18+
19+
// Handle GitHub Pages routing
20+
(function() {
21+
var l = window.location;
22+
if (l.search && l.search.indexOf('?/') !== -1) {
23+
var decoded = l.search.slice(1).split('&').map(function(s) {
24+
return s.replace(/~and~/g, '&')
25+
}).join('?');
26+
window.history.replaceState(null, null,
27+
l.pathname.slice(0, -1) + decoded + l.hash
28+
);
29+
}
30+
})();
31+
</script>
32+
<!-- Build: 1749064439 -->
933
<style>
1034
body {
1135
margin: 0;
@@ -127,8 +151,8 @@
127151
transition: opacity 0.3s ease;
128152
}
129153
</style>
130-
<script type="module" crossorigin src="/3D-Portfolio/assets/index-DCxxmV1z.js"></script>
131-
<link rel="stylesheet" crossorigin href="/3D-Portfolio/assets/index-BnuVihSM.css">
154+
<script type="module" crossorigin src="/3D-Portfolio/assets/index-BnSv7byL.js"></script>
155+
<link rel="stylesheet" crossorigin href="/3D-Portfolio/assets/index-CE_aFpHU.css">
132156
</head>
133157

134158
<body>

index.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,31 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>3D Portfolio</title>
77
<link rel="icon" type="image/x-icon" href="/favicon.ico">
8-
<!-- Fixed deployment - v3 -->
8+
<!-- GitHub Pages SPA support -->
9+
<script>
10+
// Check if we have a redirect parameter (from 404.html)
11+
(function() {
12+
var redirect = sessionStorage.redirect;
13+
delete sessionStorage.redirect;
14+
if (redirect && redirect != location.href) {
15+
history.replaceState(null, null, redirect);
16+
}
17+
})();
18+
19+
// Handle GitHub Pages routing
20+
(function() {
21+
var l = window.location;
22+
if (l.search && l.search.indexOf('?/') !== -1) {
23+
var decoded = l.search.slice(1).split('&').map(function(s) {
24+
return s.replace(/~and~/g, '&')
25+
}).join('?');
26+
window.history.replaceState(null, null,
27+
l.pathname.slice(0, -1) + decoded + l.hash
28+
);
29+
}
30+
})();
31+
</script>
32+
<!-- Fixed deployment - v4 with cache busting -->
933
<style>
1034
body {
1135
margin: 0;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"test:coverage": "vitest run --coverage",
1313
"test:ui": "vitest --ui",
1414
"generate-models": "node scripts/generate-models.js",
15-
"deploy": "npm run build"
15+
"deploy": "npm run build && npm run post-build",
16+
"post-build": "echo 'Build completed with timestamp:' && date",
17+
"force-deploy": "npm run build && echo 'Force deploying...' && git add dist && git commit -m 'Force cache bust deployment' || true"
1618
},
1719
"dependencies": {
1820
"cannon-es": "^0.20.0",

public/.nojekyll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file ensures GitHub Pages doesn't use Jekyll processing
2+
# which can interfere with ES6 modules and other modern web features

public/404.html

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,77 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Page Not Found</title>
6+
<title>3D Portfolio - Page Not Found</title>
77
<script>
8-
// Redirect to the home page
9-
const segmentCount = 1;
10-
const redirectPath = window.location.pathname.split('/').slice(0, segmentCount + 1).join('/');
11-
window.location.replace(`${redirectPath}/`);
8+
// GitHub Pages SPA redirect
9+
// This script takes the current url and converts the path and query
10+
// string into just a query string, and then redirects the browser
11+
// to the new url with only a query string and hash fragment,
12+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
13+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
14+
var l = window.location;
15+
var pathSegmentsToKeep = 1; // The number of path segments to keep (only the repository name)
16+
17+
l.replace(
18+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
19+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
20+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
21+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
22+
l.hash
23+
);
1224
</script>
1325
<style>
1426
body {
1527
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
1628
text-align: center;
17-
padding: 20px;
29+
padding: 50px 20px;
1830
background: #000;
19-
color: #fff;
31+
color: #e0e0e0;
32+
margin: 0;
33+
}
34+
.container {
35+
max-width: 600px;
36+
margin: 0 auto;
2037
}
2138
h1 {
22-
margin-top: 50px;
2339
color: #5CDED3;
40+
font-size: 2.5em;
41+
margin-bottom: 20px;
2442
}
2543
p {
2644
margin: 20px 0;
45+
font-size: 1.1em;
46+
line-height: 1.6;
47+
}
48+
.loading {
49+
animation: pulse 2s infinite;
50+
}
51+
@keyframes pulse {
52+
0% { opacity: 0.5; }
53+
50% { opacity: 1; }
54+
100% { opacity: 0.5; }
2755
}
2856
a {
2957
color: #5CDED3;
3058
text-decoration: none;
59+
border: 1px solid #5CDED3;
60+
padding: 10px 20px;
61+
display: inline-block;
62+
margin-top: 20px;
63+
transition: all 0.3s ease;
3164
}
3265
a:hover {
33-
text-decoration: underline;
66+
background: #5CDED3;
67+
color: #000;
3468
}
3569
</style>
3670
</head>
3771
<body>
38-
<h1>Page Not Found</h1>
39-
<p>Redirecting to the home page...</p>
40-
<p>If you are not redirected automatically, <a href="/3D-Portfolio/">click here</a>.</p>
72+
<div class="container">
73+
<h1>Redirecting...</h1>
74+
<p class="loading">Please wait while we redirect you to the 3D Portfolio experience.</p>
75+
<p>If you are not redirected automatically:</p>
76+
<a href="/3D-Portfolio/">Return to 3D Portfolio</a>
77+
</div>
4178
</body>
4279
</html>

public/_headers

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Cache-Control: no-cache
3+
4+
/*.html
5+
Cache-Control: no-cache, no-store, must-revalidate
6+
Pragma: no-cache
7+
Expires: 0
8+
9+
/*.js
10+
Cache-Control: public, max-age=31536000, immutable
11+
12+
/*.css
13+
Cache-Control: public, max-age=31536000, immutable
14+
15+
/*.json
16+
Content-Type: application/json
17+
18+
/*.glb
19+
Content-Type: model/gltf-binary
20+
21+
/*.gltf
22+
Content-Type: model/gltf+json
23+
24+
/*.woff2
25+
Content-Type: font/woff2
26+
27+
/*.woff
28+
Content-Type: font/woff

vite.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ export default defineConfig(({ command }) => ({
77
outDir: "dist",
88
assetsDir: "assets",
99
sourcemap: false,
10+
// Ensure proper module bundling for GitHub Pages
1011
rollupOptions: {
1112
input: resolve(__dirname, "index.html"),
13+
output: {
14+
// Better file naming with hashes for cache busting
15+
entryFileNames: 'assets/[name]-[hash].js',
16+
chunkFileNames: 'assets/[name]-[hash].js',
17+
assetFileNames: 'assets/[name]-[hash].[ext]'
18+
}
1219
},
20+
// Ensure proper module resolution
21+
target: 'esnext',
22+
minify: 'esbuild'
1323
},
1424
resolve: {
1525
alias: {
@@ -21,4 +31,12 @@ export default defineConfig(({ command }) => ({
2131
},
2232
assetsInclude: ["**/*.glsl"],
2333
publicDir: "public",
34+
// Ensure proper MIME types for GitHub Pages
35+
server: {
36+
headers: {
37+
'Access-Control-Allow-Origin': '*',
38+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
39+
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control',
40+
}
41+
}
2442
}));

0 commit comments

Comments
 (0)