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 = {
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: [
'**/*.js'
]
}
};
Import directory contents
var mySpecialDirectory = require('./my-directory-loader.config.js');
mySpecialDirectory.files.forEach((file) => {
file.module;
file.pathinfo;
});