0.0.1 • Published 8 years ago

readdir-loader v0.0.1

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

readdir-loader

load all files in given dir

basic information

  • webpack loader
  • read dir's content via 'dive' pckg
    • files and/or directories
    • recursive (if you want)

usage

targetDir tree
├── index.js
├── LICENSE
├── node_modules
├── package.json
├── README.md
└── test

const subdirs = require('readdir-loader!./targetDir')
console.log(subdirs) // ['node_modules', 'test']

const subdirs = require('readdir-loader?dirs=false&files=true!./targetDir')
console.log(subdirs) // ['index.js', 'LICENSE', 'package.json', 'README.md']

CAUTION
webpack-loaders are limited to targeting files
to enable the loader fetching the dir just add an file in the dir named "index(.js)"

options

nametypedescriptiondefault
basenameboolreturn basename?true
dirsboolinclude dirs?true
filesboolinclude files?false
recursiveboolsearch recursive?false

issues

to be done

  • npm publish
  • optimize options
  • tests