An experimental Vite plugin providing an enhanced glob import API with support for multiple patterns, ignore, custom queries, and selective default/named exports. Current version 0.3.2. It served as a design experiment that influenced Vite's built-in import.meta.glob, offering features like HMR on file changes and Vite alias support before they were integrated into core. Active development but note that Vite v3.0 has since ported some of its features, making this plugin primarily useful for experimentation or using specific options not yet in core. Key differentiator: unified API with options like eager, query, as, and import, allowing fine-grained control over globbed imports.
npm install vite-plugin-globVerified import paths — ran on the pinned version, not inferred.
Shows how to install the plugin in vite.config and use import.meta.importGlob with eager option to load all .ts files immediately.
Update usage: { export: 'default' } -> { import: 'default' }Set restoreQueryExtension: true if you need query extension restoration.
Consider using Vite's native import.meta.glob with Vite >=3.0 if you don't need this plugin's specific options.
Either enable takeover: true or use distinct patterns to avoid confusion.
Upgrade to v0.3.2 or later for improved HMR handling.
Run npm install -D vite-plugin-glob from project root.
Ensure your file is .mjs or set type: module in package.json, or use dynamic import().
Add GlobPlugin() to vite.config plugins array and restart Vite dev server.
Use import type { Options } from 'vite-plugin-glob'.