Fix Cloudflare build and MIME type issues

This commit is contained in:
colevr 2025-09-03 12:29:41 -05:00 committed by GitHub
commit 102d911e22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 18 deletions

View file

@ -4,11 +4,21 @@
# JavaScript files
/assets/*.js
Content-Type: application/javascript; charset=utf-8
# TypeScript files (should not be served in production)
/src/*.tsx
Content-Type: text/plain; charset=utf-8
Cache-Control: public, max-age=31536000, immutable
# CSS files
/assets/*.css
Content-Type: text/css; charset=utf-8
Content-Type: text/css; charset=utf-8
Cache-Control: public, max-age=31536000, immutable
# HTML files
/*.html
Content-Type: text/html; charset=utf-8
# Root HTML
/
Content-Type: text/html; charset=utf-8
# Prevent serving source files
/src/*
X-Robots-Tag: noindex

View file

@ -1,11 +1,8 @@
# Cloudflare Pages Redirects Configuration
# Handle client-side routing for React Router
# Redirect all non-asset requests to index.html for SPA routing
/* /index.html 200
# Serve built assets directly
/assets/* /assets/:splat 200
# Ensure assets are served correctly
/assets/* /assets/:splat 200
# Specific handling for source files (shouldn't be needed in production)
/src/* /index.html 200
# Redirect all other requests to index.html for SPA routing
/* /index.html 200

View file

@ -12,15 +12,15 @@ export default defineConfig(({ mode }) => ({
build: {
outDir: "dist",
assetsDir: "assets",
sourcemap: false, // Disable sourcemaps for production
sourcemap: false,
minify: 'esbuild',
target: 'es2015',
rollupOptions: {
output: {
manualChunks: undefined,
entryFileNames: `assets/[name]-[hash].js`,
chunkFileNames: `assets/[name]-[hash].js`,
assetFileNames: `assets/[name]-[hash].[ext]`,
entryFileNames: `assets/[name].[hash].js`,
chunkFileNames: `assets/[name].[hash].js`,
assetFileNames: `assets/[name].[hash].[ext]`,
},
},
},
@ -32,9 +32,8 @@ export default defineConfig(({ mode }) => ({
"@": path.resolve(__dirname, "./src"),
},
},
// Ensure proper module resolution
esbuild: {
target: 'es2015',
format: 'esm'
}
}));
}));