TrestleAdmin/trestle

View on GitHub
frontend/js/controllers/index.js

Summary

Maintainability
A
0 mins
Test Coverage
import { Application } from '@hotwired/stimulus'
import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers'

import ApplicationController from './application_controller'

window.Stimulus = Application.start()

const context = require.context('.', true, /\.js$/)
const controllerDefinitions = definitionsFromContext(context)
Stimulus.load(controllerDefinitions)

const Controllers = controllerDefinitions.reduce((result, definition) => {
  return { ...result, [definition.identifier]: definition.controllerConstructor }
}, {})

export {
  ApplicationController,
  Controllers
}