2026-02-17 20:49:42 +00:00
|
|
|
import path from 'path';
|
|
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
|
|
|
import react from '@vitejs/plugin-react';
|
2026-02-17 23:46:57 +00:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
2026-02-17 20:49:42 +00:00
|
|
|
|
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const env = loadEnv(mode, '.', '');
|
|
|
|
|
return {
|
|
|
|
|
server: {
|
|
|
|
|
port: 3000,
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
},
|
2026-02-17 23:46:57 +00:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
VitePWA({
|
|
|
|
|
registerType: 'autoUpdate',
|
2026-02-17 23:52:46 +00:00
|
|
|
injectRegister: 'auto', // Re-enable SW for installation criteria
|
2026-02-17 23:46:57 +00:00
|
|
|
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
|
|
|
|
|
manifest: {
|
|
|
|
|
name: 'FoodSnap.ai',
|
|
|
|
|
short_name: 'FoodSnap',
|
|
|
|
|
description: 'Nutricionista de Bolso com Inteligência Artificial',
|
|
|
|
|
theme_color: '#059669',
|
|
|
|
|
background_color: '#ffffff',
|
|
|
|
|
display: 'standalone',
|
|
|
|
|
orientation: 'portrait',
|
|
|
|
|
icons: [
|
|
|
|
|
{
|
|
|
|
|
src: 'pwa-192x192.png',
|
|
|
|
|
sizes: '192x192',
|
|
|
|
|
type: 'image/png'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: 'pwa-512x512.png',
|
|
|
|
|
sizes: '512x512',
|
|
|
|
|
type: 'image/png'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: 'pwa-512x512.png',
|
|
|
|
|
sizes: '512x512',
|
|
|
|
|
type: 'image/png',
|
|
|
|
|
purpose: 'any maskable'
|
|
|
|
|
}
|
|
|
|
|
]
|
2026-02-17 23:50:47 +00:00
|
|
|
},
|
|
|
|
|
workbox: {
|
2026-02-17 23:52:46 +00:00
|
|
|
// NetworkOnly strategy to prevent caching issues/lag but allow installation
|
|
|
|
|
runtimeCaching: [{
|
|
|
|
|
urlPattern: ({ request }) => request.destination === 'document' || request.destination === 'script' || request.destination === 'style' || request.destination === 'image',
|
|
|
|
|
handler: 'NetworkOnly',
|
|
|
|
|
}],
|
2026-02-17 23:50:47 +00:00
|
|
|
cleanupOutdatedCaches: true,
|
|
|
|
|
skipWaiting: true,
|
|
|
|
|
clientsClaim: true,
|
2026-02-17 23:46:57 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
],
|
2026-02-17 20:49:42 +00:00
|
|
|
define: {
|
|
|
|
|
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
|
|
|
|
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
});
|