Files
RepoDructor/nuxt.config.ts
josedario87 81330de97e
All checks were successful
build-and-deploy / build (push) Successful in 40s
build-and-deploy / deploy (push) Successful in 4s
feat(pwa-offline): Pinia store + IndexedDB; contexto para cache/eliminación; toasts; compatibilidad PWA offline
- Agrega @pinia/nuxt, idb y store central (stores/music.ts)
- Cacheo manual desde menú contextual y borrado (TrackContextMenu)
- Ícono verde para canciones cacheadas, sin auto-cache al reproducir
- Toasts de feedback (stores/toast.ts, ToastContainer)
- Fallback offline de listado a IndexedDB; fix MUSIC_DIR absoluto en preview/prod
- Ajustes PWA: navigateFallback '/', devOptions, workbox condicional
- Estilos y animación del context menu (tema light/dark, blur fuerte)
- Correcciones de sintaxis y posicionamiento exacto al cursor
2025-08-10 02:51:38 -06:00

153 lines
4.4 KiB
TypeScript

// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from 'nuxt/config'
import { resolve, isAbsolute } from 'path'
// Compute absolute music directory at build-time to avoid .output cwd issues in preview/prod
const musicDirEnv = process.env.MUSIC_DIR || './music'
const musicDirAbs = isAbsolute(musicDirEnv) ? musicDirEnv : resolve(process.cwd(), musicDirEnv)
export default defineNuxtConfig({
// Helpers
hooks: {},
compatibilityDate: '2025-08-02',
// Disable SSR completely to avoid hydration issues with client-side audio APIs
ssr: false,
devtools: {
enabled: true,
vscode: {},
timeline: {
enabled: true
}
},
// Server configuration for proxy compatibility
devServer: {
host: process.env.NUXT_HOST || '0.0.0.0',
port: process.env.NUXT_PORT ? Number(process.env.NUXT_PORT) : 3000,
https: false
},
// Additional development configuration for proxy
dev: process.env.NODE_ENV !== 'production',
// Vite configuration for HMR through proxy
vite: {
server: {
// Configure HMR via env when developing behind HTTPS proxy
hmr: process.env.NODE_ENV !== 'production' ? {
host: process.env.HMR_HOST || undefined,
clientPort: process.env.HMR_CLIENT_PORT ? Number(process.env.HMR_CLIENT_PORT) : undefined,
protocol: process.env.HMR_PROTOCOL || undefined
} : undefined
}
},
modules: [
'@vueuse/nuxt',
'@pinia/nuxt',
['@vite-pwa/nuxt', {
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'logo.png', 'logo-192.png', 'logo-512.png', 'logo-maskable-512.png', 'icon.svg'],
workbox: process.env.NODE_ENV === 'production' ? {
navigateFallback: '/',
cleanupOutdatedCaches: true,
globPatterns: [
'**/*.{js,css,html,ico,png,svg}',
'_nuxt/**/*.{js,css}',
'assets/**/*.{png,jpg,jpeg,svg,gif,webp}'
],
runtimeCaching: [
{
urlPattern: /\.(png|jpg|jpeg|svg|gif|webp)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 7 // 7 days
}
}
}
]
} : {
// Dev SW: configuración mínima y sin patrones problemáticos
navigateFallback: '/',
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
globIgnores: ['**/_payload.json', '_nuxt/builds/**/*.json'],
},
client: {
installPrompt: true,
periodicSyncForUpdates: 20
},
devOptions: {
// Permite instalar SW en dev cuando se habilita explícitamente
enabled: process.env.PWA_DEV === 'true',
type: 'module',
navigateFallback: '/'
},
manifest: {
name: 'RepoDructor Music Player',
short_name: 'RepoDructor',
description: 'A beautiful glassmorphism music player for your local network',
theme_color: '#8b5cf6', // Purple from logo gradient
background_color: '#0f172a',
display: 'standalone',
orientation: 'portrait',
scope: '/',
start_url: '/',
categories: ['music', 'entertainment'],
lang: 'es',
dir: 'ltr',
icons: [
{
src: '/logo-192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any'
},
{
src: '/logo-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: '/logo-maskable-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
},
{
src: '/logo-192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'maskable'
}
]
}
}]
],
css: ['~/assets/css/main.css'],
// Nitro configuration for proxy support
nitro: {
experimental: {
wasm: true
},
prerender: {
crawlLinks: true,
routes: ['/']
},
// Development configuration for proxy
devProxy: process.env.NODE_ENV === 'development' ? {} : undefined
},
// Runtime configuration
runtimeConfig: {
musicDirAbs,
public: {
musicPath: process.env.NUXT_PUBLIC_MUSIC_PATH || '/music'
}
},
})