Webpack resolve plugin that allows using a file named after its directory (e.g., foo/foo.js) instead of index.js as the entry point for directory imports. v4.1.0 supports Webpack >=4, with v2.x for Webpack 2/3 and v1.x for Webpack 1. Configurable via options like honorIndex, honorPackage, exclude, include, transformFn, and resolverHook. Provides fine-grained control over resolve behavior per directory, overcoming the limitation of always using index files.
npm install directory-named-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
CommonJS webpack config using DirectoryNamedWebpackPlugin with exclude and include options.
Use v2.x for webpack 2/3, v1.x for webpack 1.
new DirectoryNamedWebpackPlugin({ honorIndex: true })Add exclude: /node_modules/ or specify include paths to restrict scope.
Use new DirectoryNamedWebpackPlugin({ honorIndex: true }) instead of new DirectoryNamedWebpackPlugin(true).Only change resolverHook if you understand webpack's resolver plugins deeply.
Set honorIndex: false or ensure the directory has a file named after it. Check include/exclude settings.
Use require('directory-named-webpack-plugin') or dynamic import with default property: const { default: DirNamedPlugin } = await import('directory-named-webpack-plugin')Update the plugin to latest version or use resolverHook: 'directory' or 'resolve' as fallback (check webpack docs).