-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actualiza a rails 7.1, esbuild 0.19 y msip 2.2.0.beta4. Ver https://g…
- Loading branch information
Showing
11 changed files
with
159 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file is used by Rack-based servers to start the application. | ||
|
||
require_relative "config/environment" | ||
|
||
run Rails.application | ||
Rails.application.load_server | ||
rutarel = ENV.fetch("RUTA_RELATIVA", "msip/") | ||
if rutarel[0] != '/' | ||
rutarel = "/" + rutarel | ||
end | ||
map rutarel do | ||
run Rails.application | ||
Rails.application.load_server | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// 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 | ||
|
||
import * as path from "path" | ||
import * as http from "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 | ||
} | ||
} | ||
} | ||
|
||
import * as esbuild from 'esbuild' | ||
|
||
if (watch && watchOptions) { | ||
let ctx = await esbuild.context({ | ||
entryPoints: ['application.js'], | ||
bundle: true, | ||
preserveSymlinks: true, | ||
outdir: path.join(process.cwd(), "app/assets/builds"), | ||
absWorkingDir: path.join(process.cwd(), "app/javascript"), | ||
banner: { | ||
js: ` (() => new EventSource("http://${process.env.MAQRECVIVA}:${process.env.PUERTORECVIVA}").onmessage = () => location.reload())();`, | ||
} | ||
}) | ||
await ctx.watch() | ||
} else { | ||
let result = esbuild.build({ | ||
entryPoints: ["application.js"], | ||
bundle: true, | ||
preserveSymlinks: true, | ||
outdir: path.join(process.cwd(), "app/assets/builds"), | ||
absWorkingDir: path.join(process.cwd(), "app/javascript"), | ||
banner: { | ||
js: ` (() => new EventSource("http://${process.env.MAQRECVIVA}:${process.env.PUERTORECVIVA}").onmessage = () => location.reload())();`, | ||
} | ||
}).catch(() => process.exit(1)); | ||
console.log(result); | ||
} | ||
|
||
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); | ||
|
Oops, something went wrong.