Skip to content

Instantly share code, notes, and snippets.

@benbonnet
Created September 27, 2023 04:28
Show Gist options
  • Select an option

  • Save benbonnet/9354fedbf6aa106d3e8a71db69381132 to your computer and use it in GitHub Desktop.

Select an option

Save benbonnet/9354fedbf6aa106d3e8a71db69381132 to your computer and use it in GitHub Desktop.

Revisions

  1. benbonnet revised this gist Sep 27, 2023. No changes.
  2. benbonnet created this gist Sep 27, 2023.
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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);
    }
    });