Rollup and Vite plugin that flattens a directory's file contents into a `Record<string, string>` object. Version 1.0.1 is the current stable release, with no active development observable. It resolves a directory, reads file contents, filters by include/exclude glob patterns, and generates an ESM module with a default export mapping relative file paths to their raw string contents. Optionally generates TypeScript declaration files. Differentiates from similar plugins by focusing on raw string contents rather than module transforms.
npm install rollup-plugin-flatten-dirVerified import paths — ran on the pinned version, not inferred.
Basic Rollup configuration using flattenDirPlugin to include JSON files from src/data, excluding node_modules.
Add exclude: ['**/node_modules/**'] to plugin options.
Use include or exclude patterns to limit to text files (e.g., include: ['**/*.json', '**/*.txt']).
Always provide an absolute path or a relative path from process.cwd() to avoid unexpected behavior.
Use default import: import flattenDirPlugin from 'rollup-plugin-flatten-dir'
Run npm install rollup-plugin-flatten-dir
Change import { flattenDirPlugin } from ... to import flattenDirPlugin from ...Ensure the directory specified in resolve exists and is accessible.