1.0.4 • Published 7 years ago

directory-loader v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

directory-loader

A loader that loads a whole directory

Usage

Install

npm install --save directory-loader

Webpack configurations

In webpack.config.js file

module.exports = {
  /* Omitted */
  module: {
    loaders: [
      {
        test: require.resolve('./my-directory-loader.config.js'),
        loader: 'directory-loader'
      }
    ]
  }
};

In directory-loader config file

module.exports = {
  files: {
    root: './my-special-directory',
    globs: [
      /* Make sure that files matched can be handled by your webpack loaders */
      '**/*.js'
    ]
  }
};

Import directory contents

var mySpecialDirectory = require('./my-directory-loader.config.js');

mySpecialDirectory.files.forEach((file) => {
  file.module; // The module exported by the processed file
  file.pathinfo; // path data about the file
});