Add index.html with Stimulus hello controller
This commit is contained in:
parent
b280d54f77
commit
d379fdb73d
9 changed files with 524 additions and 0 deletions
32
assets/esbuild.config.mjs
Normal file
32
assets/esbuild.config.mjs
Normal file
|
@ -0,0 +1,32 @@
|
|||
import * as esbuild from 'esbuild';
|
||||
import { stimulusPlugin } from 'esbuild-plugin-stimulus';
|
||||
|
||||
let minify = false;
|
||||
let sourcemap = true;
|
||||
let watch = true;
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
minify = true;
|
||||
sourcemap = false;
|
||||
watch = false;
|
||||
}
|
||||
|
||||
const config = {
|
||||
bundle: true,
|
||||
entryPoints: ['./assets/js/app.js'],
|
||||
minify,
|
||||
outdir: './public/build',
|
||||
plugins: [stimulusPlugin()],
|
||||
sourcemap,
|
||||
}
|
||||
|
||||
if (watch) {
|
||||
let context = await esbuild.context({
|
||||
...config,
|
||||
logLevel: 'info',
|
||||
});
|
||||
|
||||
await context.watch()
|
||||
} else {
|
||||
esbuild.build(config)
|
||||
}
|
5
assets/js/app.js
Normal file
5
assets/js/app.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { Application } from "@hotwired/stimulus";
|
||||
import { definitions } from "stimulus:./controllers";
|
||||
|
||||
const app = Application.start();
|
||||
app.load(definitions);
|
7
assets/js/controllers/hello_controller.js
Normal file
7
assets/js/controllers/hello_controller.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
console.log("hello#connect");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue