Skip to content

A esbuild plugin which allows to import multiple files using the glob syntax.

License

Notifications You must be signed in to change notification settings

barcicki/esbuild-plugin-import-glob

 
 

Repository files navigation

esbuild-plugin-import-glob

A esbuild plugin which allows to import multiple files using the glob syntax.

Basic Usage

  1. Install this plugin in your project:

    npm install --save-dev esbuild-plugin-import-glob
  2. Add this plugin to your esbuild build script:

    +const ImportGlobPlugin = require('esbuild-plugin-import-glob');
     ...
     esbuild.build({
       ...
       plugins: [
    +    ImportGlobPlugin(),
       ],
     })
  3. Use import or require

    // @ts-ignore
    import migrationsArray from './migrations/**/*';
    
    // contains default export
    migrationsArray[0].default;
    // @ts-ignore
    import * as migrations from './migrations/**/*';
    
    const { default: migrationsArray, filenames } = migrations;
    const { default: migrationsArray, filenames } = require('./migrations/**/*');

About

A esbuild plugin which allows to import multiple files using the glob syntax.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 88.9%
  • JavaScript 11.1%