2.0.0 • Published 8 years ago

@gustavnikolaj/directory-named-webpack-plugin v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

What

Normally, Webpack looks for index file when the path passed to require points to a directory; which means there may have a lot of index files.

This plugin makes it possible to use the name of the directory as the name of the entry file, makes it easier to find.

Usage

Add the following to Webpack's config file:

  var DirectoryNamedWebpackPlugin = require("directory-named-webpack-plugin");

  plugins: [
    new webpack.ResolverPlugin(new DirectoryNamedWebpackPlugin())
  ]

Then when require("component/foo") and the path "component/foo" is resolved to a directory, Webpack will try to look for component/foo/foo.js as the entry.

If there is also an index file, e.g. index.js, and it should be used as entry file instead of the file with the same name of directory, pass true as the first argument when creating new instace.

  var DirectoryNamedWebpackPlugin = require("directory-named-webpack-plugin");

  plugins: [
    new webpack.ResolverPlugin(new DirectoryNamedWebpackPlugin(true))
  ]