Webpack loader enabling glob patterns in ES6 import statements and Sass @import/@use/@forward directives. Version 2.0.0 supports Webpack 5 and enhanced-resolver for alias resolution. Expands globs like `import modules from './foo/**/*.js'` into multiple named imports. Unlike alternatives, it works seamlessly with Sass (scss/sass) files and allows configuration of resolve aliases, banner function for HMR, and node_modules filtering. Requires Node >=15 and Webpack 5.
npm install glob-import-loaderVerified import paths — ran on the pinned version, not inferred.
Demonstrates webpack config using glob-import-loader for JS and SCSS files, with resolve alias and both named and side-effect glob imports.
Avoid using ? + and ! in glob patterns; use * and ** only.
Do not use configuration syntax in glob-based @use/@forward; configure each module individually.
Upgrade to Webpack 5 or use version 1.x for Webpack 4.
Do not rely on node_modules globbing unless you explicitly include 'node_modules' in the pattern.
Access each module's exports via array index or iteration (e.g., modules[0].default).
Ensure webpack config has a rule with test: /\.js$/ and use: 'glob-import-loader'.
Iterate over the default import: modules.forEach(mod => console.log(mod));
Remove configuration from glob-based @use; configure each module individually.
Upgrade to Webpack 5 and ensure enhanced-resolver is installed.