Sha256: 223f991b9060de17cf3bed518b60cb3eaa84b0972a22949a9013ae5457b94530
Contents?: true
Size: 1.42 KB
Versions: 25
Compression:
Stored size: 1.42 KB
Contents
import {Application, type ControllerConstructor} from '@hotwired/stimulus' const application = Application.start() application.debug = import.meta.env.DEV declare global { interface Window { Stimulus: Application } } window.Stimulus = application // Force Vite to process component JS const componentModules = import.meta.glob(['../../components/**/component.ts'], {eager: true}) import.meta.glob(['../../components/**/component.css'], {eager: true}) for (const [path, module] of Object.entries(componentModules)) { const dirs = path.split('/') // Dropping ../../components and component.ts parts to end up // with something like "ariadne-ui-component-name" const name = dirs .slice(3, dirs.length - 1) .join('-') .replaceAll('_', '-') .toLocaleLowerCase() application.register( // @tag stimulus-id name, (module as {default: ControllerConstructor}).default, ) } const controllerModules = import.meta.glob(['~/controllers/*.ts'], {eager: true}) for (const [path, module] of Object.entries(controllerModules)) { const dirs = path.split('/') // Dropping ../controllers to end up // with something like "ariadne-controllername" const name = dirs[dirs.length - 1].replace('_controller.ts', '').replaceAll('_', '-').toLocaleLowerCase() application.register( // @tag stimulus-id `ariadne-${name}`, (module as {default: ControllerConstructor}).default, ) } export {application}
Version data entries
25 entries across 25 versions & 1 rubygems