-
-
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.
Puede usar controladores stimulus de motores, y en modo desarrolo usa…
… foreman y recarga viva
- Loading branch information
Showing
12 changed files
with
134 additions
and
15 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
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,2 @@ | ||
rails: R=f bin/corre | ||
js: yarn start --watch |
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 |
---|---|---|
|
@@ -51,3 +51,4 @@ document.addEventListener('turbo:load', (e) => { | |
sip_ejecutarAlCargarPagina(window) | ||
}) | ||
|
||
import "./controllers" |
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,9 @@ | ||
import { Application } from "@hotwired/stimulus" | ||
|
||
const application = Application.start() | ||
|
||
// Configure Stimulus development experience | ||
application.debug = false | ||
window.Stimulus = application | ||
|
||
export { application } |
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,7 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
connect() { | ||
this.element.textContent = "Hello World!" | ||
} | ||
} |
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,8 @@ | ||
// This file is auto-generated by ./bin/rails stimulus:manifest:update | ||
// Run that command whenever you add a new controller or create them with | ||
// ./bin/rails generate stimulus controllerName | ||
|
||
import { application } from "./application" | ||
|
||
import HelloController from "./hello_controller" | ||
application.register("hello", HelloController) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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); | ||
|
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