Skip to content

Instantly share code, notes, and snippets.

@benbonnet
Created September 27, 2023 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbonnet/9354fedbf6aa106d3e8a71db69381132 to your computer and use it in GitHub Desktop.
Save benbonnet/9354fedbf6aa106d3e8a71db69381132 to your computer and use it in GitHub Desktop.
autoload.js
const controllers = import.meta.glob('../../components/**/index.(js|jsx)', {
eager: true
});
Object.keys(controllers).forEach(path => {
const mod = controllers[path].default;
if (mod) {
const splittedPath = path.split('/');
const identifier = splittedPath[splittedPath.length - 2];
app.register(identifier, controllers[path].default);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment