webpack-entry-list
v1.0.1
Published
Generate an Entry Point Object for Webpack
Maintainers
Readme
webpack-entry-list
A tiny utility which helps generate an Entry Point Object for Webpack based on contents of a folder. This can also be used to generate an array of HTML Webpack Plugin objects based on contents of a folder.
Note that this has only been tested with Webpack 4.
Installation
npm install webpack-entry-list --save-devUsage
There are two static methods, generateEntryList and generateHTMLPluginList, used as given below.
generateEntryList(directoryPath[,fileExtension])
directoryPath: Relative path to a directory.
fileExtension: Extension of files to be used as entry points. Defaults to .js.
// webpack.config.js
...
const WebpackEntryList = require('webpack-entry-list');
...
const config = [{
...
entry: WebpackEntryList.generateEntryList('src/js')
...
}];
module.exports = config;generateHTMLPluginList(directoryPath[,fileExtension, HTMLWebpackPluginOptions])
directoryPath: Relative path to a directory.
fileExtension: Extension of files to be used as entry points. Defaults to .pug.
HTMLWebpackPluginOptions: HTMLWebpackPlugin options object. Defaults to { inject: true }.
// webpack.config.js
...
const WebpackEntryList = require('webpack-entry-list');
let HTMLWebpackPluginList = WebpackEntryList.generateHTMLPluginList('src/pug');
...
const config = [{
...
plugins: [...HTMLWebpackPluginList]
...
}];
module.exports = config;Note the use of ... before the HTMLWebpackPluginList variable. This is Spread Syntax.
