101 lines
3.8 KiB
JavaScript
101 lines
3.8 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
|
|
import path from 'path';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
// Lade Umgebungsvariablen explizit
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
// Kombiniere mit process.env, um auch Shell-Umgebungsvariablen zu berücksichtigen
|
|
const combinedEnv = { ...env, ...process.env };
|
|
|
|
return {
|
|
plugins: [vue()],
|
|
define: {
|
|
// Explizit Produktionsumgebung setzen
|
|
__DEV__: false,
|
|
'import.meta.env.DEV': false,
|
|
'import.meta.env.PROD': true,
|
|
'import.meta.env.MODE': '"production"',
|
|
// Stelle sicher, dass Umgebungsvariablen aus .env.production oder Shell-Umgebung geladen werden
|
|
...(combinedEnv.VITE_DAEMON_SOCKET && {
|
|
'import.meta.env.VITE_DAEMON_SOCKET': JSON.stringify(combinedEnv.VITE_DAEMON_SOCKET)
|
|
}),
|
|
...(combinedEnv.VITE_API_BASE_URL && {
|
|
'import.meta.env.VITE_API_BASE_URL': JSON.stringify(combinedEnv.VITE_API_BASE_URL)
|
|
}),
|
|
...(combinedEnv.VITE_CHAT_WS_URL && {
|
|
'import.meta.env.VITE_CHAT_WS_URL': JSON.stringify(combinedEnv.VITE_CHAT_WS_URL)
|
|
}),
|
|
...(combinedEnv.VITE_SOCKET_IO_URL && {
|
|
'import.meta.env.VITE_SOCKET_IO_URL': JSON.stringify(combinedEnv.VITE_SOCKET_IO_URL)
|
|
}),
|
|
...(combinedEnv.VITE_PUBLIC_BASE_URL && {
|
|
'import.meta.env.VITE_PUBLIC_BASE_URL': JSON.stringify(combinedEnv.VITE_PUBLIC_BASE_URL)
|
|
})
|
|
},
|
|
optimizeDeps: {
|
|
include: ['three', 'three/addons/loaders/GLTFLoader.js', 'three/addons/loaders/DRACOLoader.js'],
|
|
esbuildOptions: {
|
|
plugins: [
|
|
NodeGlobalsPolyfillPlugin({
|
|
buffer: true
|
|
}),
|
|
NodeModulesPolyfillPlugin()
|
|
]
|
|
}
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
stream: 'stream-browserify',
|
|
util: 'util',
|
|
assert: 'assert',
|
|
},
|
|
dedupe: ['three'],
|
|
preserveSymlinks: false
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (!id.includes('node_modules')) {
|
|
return;
|
|
}
|
|
|
|
if (id.includes('@tiptap')) {
|
|
return 'vendor-editor';
|
|
}
|
|
|
|
if (id.includes('vuetify')) {
|
|
return 'vendor-vuetify';
|
|
}
|
|
|
|
if (id.includes('socket.io-client')) {
|
|
return 'vendor-realtime';
|
|
}
|
|
|
|
if (id.includes('axios') || id.includes('dompurify')) {
|
|
return 'vendor-utils';
|
|
}
|
|
|
|
if (id.includes('vue-router') || id.includes('vuex') || id.includes('vue-i18n')) {
|
|
return 'vendor-vue-ecosystem';
|
|
}
|
|
|
|
if (id.includes('vue')) {
|
|
return 'vendor-vue';
|
|
}
|
|
}
|
|
},
|
|
external: [] // Explizit keine externen Module
|
|
},
|
|
commonjsOptions: {
|
|
include: [/three/, /node_modules/],
|
|
transformMixedEsModules: true
|
|
}
|
|
},
|
|
};
|
|
});
|