Files
openfoodnetwork/app/webpacker/controllers/index.js
David Cook 6e5154b922 add stimulus-rails-nested-form
The official instructions (https://www.stimulus-components.com/docs/stimulus-rails-nested-form) don't quite work, because of an issue with this component (https://stackoverflow.com/a/76715129). So we work around for now by using the umd file instead.
2024-02-15 17:32:08 +11:00

22 lines
1.1 KiB
JavaScript

// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
import { Application } from "stimulus";
import { definitionsFromContext } from "stimulus/webpack-helpers";
import StimulusReflex from "stimulus_reflex";
import consumer from "../channels/consumer";
import controller from "../controllers/application_controller";
import CableReady from "cable_ready";
import NestedForm from 'stimulus-rails-nested-form/dist/stimulus-rails-nested-form.umd.js' // the default module entry point is broken
const application = Application.start();
const context = require.context("controllers", true, /_controller\.js$/);
const contextComponents = require.context("../../components", true, /_controller\.js$/);
application.load(definitionsFromContext(context).concat(definitionsFromContext(contextComponents)));
application.register('nested-form', NestedForm);
application.consumer = consumer;
StimulusReflex.initialize(application, { controller, isolate: true });
StimulusReflex.debug = process.env.RAILS_ENV === "development";
CableReady.initialize({ consumer });