Move all files to stimulus-esbuild/
This commit is contained in:
parent
4c850b3b40
commit
7588eb0c98
14 changed files with 0 additions and 0 deletions
32
stimulus-esbuild/assets/esbuild.config.mjs
Normal file
32
stimulus-esbuild/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
stimulus-esbuild/assets/js/app.js
Normal file
5
stimulus-esbuild/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);
|
||||
45
stimulus-esbuild/assets/js/controllers/count_controller.js
Normal file
45
stimulus-esbuild/assets/js/controllers/count_controller.js
Normal 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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