Skip to content

Teach webpack to use the name of the directory as the main file for a module

Notifications You must be signed in to change notification settings

elastic/webpack-directory-name-as-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@elastic/webpack-directory-name-as-main

Teach webpack to use a file with the same name as the directory if that directory is required and it doesn't have an index.js file.

This allows you to write:

require('lib/ReallyImportantModule')

inorder to require:

lib/ReallyImportantModule/ReallyImportantModule.js

This module is designed to be used as strategy for a webpack.ResolverPlugin like so:

var DirectoryNameAsMain = require('@elastic/webpack-directory-name-as-main');
var webpackConfig = {
  entry: ...,

  plugins: [
    new webpack.ResolverPlugin([
      new DirectoryNameAsMain()
    ]),
    ...
  ]
};

About

Teach webpack to use the name of the directory as the main file for a module

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •