Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
183
vite.config.js
183
vite.config.js
@@ -1,95 +1,114 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import {VitePWA} from "vite-plugin-pwa";
|
||||
import * as fs from "node:fs";
|
||||
// Optional: TypeScript support ist ohne extra Plugin enthalten!
|
||||
// Bei Bedarf: npm install --save-dev typescript
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: 'dist', // Output bleibt im public-Verzeichnis
|
||||
manifest: true,
|
||||
emptyOutDir: true,
|
||||
outDir: 'public', // Direct output to public directory
|
||||
manifest: '.vite/manifest.json', // Put manifest in .vite subfolder
|
||||
emptyOutDir: false, // Don't delete existing public files
|
||||
assetsDir: 'assets',
|
||||
|
||||
// Performance optimizations
|
||||
minify: 'terser',
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: false, // Keep console.log for debugging
|
||||
drop_debugger: true
|
||||
}
|
||||
},
|
||||
|
||||
// Chunk optimization to prevent excessive fragmentation
|
||||
rollupOptions: {
|
||||
input: {
|
||||
css: resolve(__dirname, 'resources/css/styles.css'),
|
||||
js: resolve(__dirname, 'resources/js/main.js')
|
||||
// Falls TypeScript:
|
||||
// ts: 'resources/ts/app.ts'
|
||||
main: resolve(import.meta.dirname, 'resources/js/main.js')
|
||||
},
|
||||
plugins: []
|
||||
output: {
|
||||
// Simplified chunking - disable manual chunking to let Vite handle it naturally
|
||||
// manualChunks: undefined,
|
||||
|
||||
// Optimize chunk sizes
|
||||
chunkFileNames: 'assets/js/[name]-[hash].js',
|
||||
entryFileNames: 'assets/js/[name]-[hash].js',
|
||||
assetFileNames: (assetInfo) => {
|
||||
const info = assetInfo.name.split('.');
|
||||
const ext = info[info.length - 1];
|
||||
|
||||
if (/\.(png|jpe?g|svg|gif|tiff|bmp|ico)$/i.test(assetInfo.name)) {
|
||||
return `assets/images/[name]-[hash].${ext}`;
|
||||
}
|
||||
|
||||
if (/\.css$/i.test(assetInfo.name)) {
|
||||
return `assets/css/[name]-[hash].${ext}`;
|
||||
}
|
||||
|
||||
return `assets/[name]-[hash].${ext}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Compression and optimization
|
||||
reportCompressedSize: true,
|
||||
chunkSizeWarningLimit: 1000,
|
||||
|
||||
// Source maps for production debugging
|
||||
sourcemap: 'hidden'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// PWA plugin temporarily disabled due to build issues
|
||||
// VitePWA({ ... })
|
||||
],
|
||||
|
||||
// Optimized development server
|
||||
server: {
|
||||
https: (() => {
|
||||
try {
|
||||
if (fs.existsSync('./ssl/localhost.pem') && fs.existsSync('./ssl/localhost-key.pem')) {
|
||||
return {
|
||||
key: fs.readFileSync('./ssl/localhost-key.pem'),
|
||||
cert: fs.readFileSync('./ssl/localhost.pem')
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('SSL certificates not found, falling back to HTTP');
|
||||
}
|
||||
return false;
|
||||
})(),
|
||||
host: true,
|
||||
port: 3000,
|
||||
open: false,
|
||||
hmr: {
|
||||
overlay: true
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
VitePWA({
|
||||
filename: 'sw.js',
|
||||
registerType: 'autoUpdate',
|
||||
includeAssets: [
|
||||
'favicon.svg',
|
||||
'offline.html',
|
||||
'icons/icon-192x192.png',
|
||||
'icons/icon-512x512.png'
|
||||
],
|
||||
manifest: {
|
||||
name: 'Meine Website',
|
||||
short_name: 'Website',
|
||||
start_url: '/',
|
||||
display: 'standalone',
|
||||
background_color: '#ffffff',
|
||||
theme_color: '#000000',
|
||||
icons: [
|
||||
{
|
||||
src: 'icons/icon-192x192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png'
|
||||
},
|
||||
{
|
||||
src: 'icons/icon-512x512.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png'
|
||||
}
|
||||
]
|
||||
},
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ request }) => request.destination === 'document',
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'html-cache'
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: ({ request }) =>
|
||||
request.destination === 'script' || request.destination === 'style',
|
||||
handler: 'StaleWhileRevalidate',
|
||||
options: {
|
||||
cacheName: 'asset-cache'
|
||||
}
|
||||
},
|
||||
{
|
||||
urlPattern: ({ request }) => request.destination === 'image',
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'image-cache',
|
||||
expiration: {
|
||||
maxEntries: 50,
|
||||
maxAgeSeconds: 60 * 60 * 24 * 30
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
navigateFallback: '/offline.html'
|
||||
|
||||
// CSS optimization
|
||||
css: {
|
||||
devSourcemap: true,
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
additionalData: '@import "resources/css/settings/variables.css";'
|
||||
}
|
||||
})
|
||||
],
|
||||
server: {
|
||||
https: {
|
||||
key: fs.readFileSync('./ssl/fullchain.pem'),
|
||||
cert: fs.readFileSync('./ssl/privkey.pem')
|
||||
},
|
||||
host: 'localhost',
|
||||
//port: 3000
|
||||
}
|
||||
},
|
||||
|
||||
// Dependency optimization
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
// Pre-bundle known dependencies
|
||||
],
|
||||
exclude: [
|
||||
// Exclude problematic dependencies
|
||||
]
|
||||
},
|
||||
|
||||
// Asset handling
|
||||
assetsInclude: ['**/*.woff2', '**/*.woff', '**/*.ttf'],
|
||||
|
||||
// Development environment
|
||||
define: {
|
||||
__DEV__: JSON.stringify(process.env.NODE_ENV !== 'production')
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user