Sha256: 301e619fad41cb510e69fc064e539d4f0e21c7ef50e0bf3b192084759291e879
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
// Recarga viva (live reloading) durante desarrollo // Recompila automáticamente ante cambios en javascript de app/javascript // y refresca automáticamente en navegador // Basado en https://www.colby.so/posts/live-reloading-with-esbuild-and-rails const path = require('path') const http = require('http') const watch = process.argv.includes('--watch') const clients = [] const watchOptions = { onRebuild: (error, result) => { if (error) { console.error('Falló construcción:', error) } else { console.log('Construcción exitosa') clients.forEach((res) => res.write('data: update\n\n')) clients.length = 0 } } } require("esbuild").build({ entryPoints: ["application.js"], bundle: true, preserveSymlinks: true, outdir: path.join(process.cwd(), "app/assets/builds"), absWorkingDir: path.join(process.cwd(), "app/javascript"), watch: watch && watchOptions, banner: { js: ` (() => new EventSource("http://${process.env.MAQRECVIVA}:${process.env.PUERTORECVIVA}").onmessage = () => location.reload())();`, }, }).catch(() => process.exit(1)); http.createServer((req, res) => { return clients.push( res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", "Access-Control-Allow-Origin": "*", Connection: "keep-alive", }), ); }).listen(process.env.PUERTORECVIVA, process.env.IPDES);
Version data entries
4 entries across 4 versions & 1 rubygems