Sha256: f9fde4791d1bdfd149dce2aed2e4a5e6c0b9ef0d797eaa2539243619c9465193
Contents?: true
Size: 1.43 KB
Versions: 20
Compression:
Stored size: 1.43 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-component-name" const name = dirs.slice(2, dirs.length).join('-').replace('.ts', '').replaceAll('_', '-').toLocaleLowerCase() application.register( // @tag stimulus-id `ariadne-${name}`, (module as {default: ControllerConstructor}).default, ) } export {application}
Version data entries
20 entries across 20 versions & 1 rubygems