-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
65 lines (60 loc) · 2.27 KB
/
Copy pathvite.config.ts
File metadata and controls
65 lines (60 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { writeFileSync } from 'fs'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig(() => {
// Load env file from .env
const env = loadEnv('', process.cwd(), '')
return {
plugins: [
react(),
// Custom plugin to generate riot.txt
{
name: 'generate-riot-txt',
buildStart() {
// Get the Riot key from loaded environment
const riotKey = env.VITE_RIOT_KEY || env.RIOT_KEY || '';
const riotFilePath = resolve(__dirname, 'public', 'riot.txt');
try {
console.log('🔍 Environment variables loaded:');
console.log('📋 VITE_RIOT_KEY:', env.VITE_RIOT_KEY ? 'Found' : 'Not found');
console.log('📋 RIOT_KEY:', env.RIOT_KEY ? 'Found' : 'Not found');
console.log('📋 All VITE_ vars:', Object.keys(env).filter(key => key.startsWith('VITE_')));
if (!riotKey) {
console.warn('⚠️ No Riot key found in environment variables');
console.warn('💡 Make sure VITE_RIOT_KEY is set in your .env file');
}
writeFileSync(riotFilePath, riotKey);
console.log('✅ riot.txt generated successfully');
console.log('📝 Key length:', riotKey.length, 'characters');
console.log('🔑 Key preview:', riotKey ? `${riotKey.substring(0, 8)}...` : 'EMPTY');
console.log('📁 File path:', riotFilePath);
} catch (error) {
console.error('❌ Error generating riot.txt:', error);
}
}
}
],
build: {
// Enable code splitting and optimize chunk size
rollupOptions: {
output: {
manualChunks: {
// Vendor chunk for React and related libraries
vendor: ['react', 'react-dom', 'react-router-dom'],
// Supabase chunk
supabase: ['@supabase/supabase-js'],
ui: ['lucide-react', 'react-hot-toast']
}
}
},
// Optimize chunk size
chunkSizeWarningLimit: 1000
},
// Optimize dependencies
optimizeDeps: {
include: ['react', 'react-dom', 'react-router-dom', '@supabase/supabase-js']
}
}
})