Skip to content

charlie043/require-index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

require-index

Generate flat index file require all files in directory. useful for react front-end project.

install

$ npm install -g require-index

use

./components
├── ComponentA.js
├── ComponentB.js
├── ComponentC.js
├── ComponentD.js
├── ComponentE.js
└── ComponentF.js
$ cd components
$ require-index

output

// ./index.js
module.exports = {
  ComponentA: require('./ComponentA.js'),
  ComponentB: require('./ComponentB.js'),
  ComponentC: require('./ComponentC.js'),
  ComponentD: require('./ComponentD.js'),
  ComponentE: require('./ComponentE.js'),
  ComponentF: require('./ComponentF.js')
};

use component

var {
  ComponentA,
  ComponentB,
  ...
} = require('./components');

options

  • -f, --force overwrite index.js
  • -e, --extension ('js', 'jsx')

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published