A Rollup plugin that generates Single Directory Components (SDCs) for embedding JavaScript applications into Drupal modules or themes. Current stable version is 1.1.11, released with moderate maintenance cadence. It automates creation of .component.yml, .twig, and other SDC files from templates, replacing placeholders like [name] with component names. Supports both string and object configuration for template directories. Designed specifically for Drupal integration, differentiating from generic Rollup plugins by handling Drupal's SDC structure. Works with Vite via Rollup options and targets Drupal module/theme bundlers.
npm install rollup-plugin-drupal-sdc-generatorVerified import paths — ran on the pinned version, not inferred.
Minimal Rollup configuration using the plugin with optional custom template directory.
Move plugin instantiation to `build.rollupOptions.plugins` in Vite config.
Provide a `directory` option pointing to your own templates.
Escape with backslash: `\[name\]` to include literal `[name]`.
Use `import` syntax or dynamic `import()`.
Use object form of `directory` to map multiple component names to their template directories.
Change to `import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'` and ensure your project is ESM (type: module in package.json or use .mjs extension).
Use `import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'` without curly braces.
Move the plugin inside `build.rollupOptions.plugins` array in your Vite config.