Fix .htaccess handling in Vite build

This commit is contained in:
2025-12-04 20:15:56 +02:00
parent 005fb89254
commit 69290f3192
3 changed files with 21 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
},
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"build": "run-p type-check \"build-only {@}\" -- && cp public/.htaccess dist/.htaccess",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build",

View File

@@ -1,8 +1,21 @@
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
RewriteRule ^ index.html [L]
</IfModule>

View File

@@ -17,4 +17,8 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
publicDir: 'public',
build: {
copyPublicDir: true,
},
})