Move all files to stimulus-esbuild/

This commit is contained in:
Oliver Davies 2025-09-29 22:53:27 +01:00
parent 4c850b3b40
commit 7588eb0c98
14 changed files with 0 additions and 0 deletions

View 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)
}

View file

@ -0,0 +1,5 @@
import { Application } from "@hotwired/stimulus";
import { definitions } from "stimulus:./controllers";
const app = Application.start();
app.load(definitions);

View file

@ -0,0 +1,45 @@
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static targets = ["result"];
static values = {
canBeNegative: Boolean,
count: Number,
maximumCountNumber: Number,
};
connect() {
console.log("count#connect");
this.resultTarget.textContent = this.countValue;
}
countValueChanged() {
console.log("count#countValueChanged");
this.resultTarget.textContent = this.countValue;
}
decrement() {
console.log("count#decrement");
if (this.canBeNegativeValue === false && this.countValue === 0) {
return;
}
this.countValue = this.countValue - 1;
}
increment() {
console.log("count#increment");
const maximumCountNumber = this.maximumCountNumberValue || 10;
if (this.countValue === maximumCountNumber) {
return;
}
this.countValue = this.countValue + 1;
}
}

View file

@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
connect() {
console.log("hello#connect");
}
}