esbuild-plugin-stimulus
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.2 • Public • Published

    esbuild-plugin-stimulus

    esbuild plugin for automatically loading Stimulus controllers from a folder. For example, if you create controllers/users/list_item_controller.js, then your Stimulus controller will be available as users--list-item.

    Install

    npm install --save-dev esbuild-plugin-stimulus

    Usage

    In your esbuild script:

    // build.js
    
    const esbuild = require('esbuild');
    const { stimulusPlugin } = require('esbuild-plugin-stimulus');
    
    esbuild.build({
      plugins: [stimulusPlugin()],
      // ...
    }).catch(() => process.exit(1));

    And in your application (similar to using webpack):

    // app.js
    
    import { Application } from 'stimulus';
    import { definitions } from 'stimulus:./controllers';
    
    const app = Application.start();
    app.load(definitions);

    If you are using Typescript, add a declaration file like the following to your project to provide type information for stimulus: imports:

    // esbuild-plugin-stimulus.d.ts
    
    declare module 'stimulus:*' {
      import type { Definition } from 'stimulus';
      export const definitions: Definition[];
    }

    License

    Apache 2.0

    Install

    npm i esbuild-plugin-stimulus

    DownloadsWeekly Downloads

    412

    Version

    0.1.2

    License

    Apache-2.0

    Unpacked Size

    36.2 kB

    Total Files

    13

    Last publish

    Collaborators

    • zombiezen