Fix Cloudflare build and MIME type issues
This commit is contained in:
parent
4e75294540
commit
102d911e22
3 changed files with 24 additions and 18 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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'
|
||||
}
|
||||
}));
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue