webpack-config-htmls
v1.0.1
Published
small module to configure all html files found in your source folder with webpack
Downloads
5
Readme
webpack-config-htmls (1.0.0)
Maintainer: Geoffrey Dhuyvetters @duivvv
Installation
Install the plugin with npm:
$ npm install webpack-config-htmls --save-dev
Basic Usage
var configHTMLs = require('webpack-config-htmls')();
//config is a webpack config object
config.entry = config.entry.concat(htmls.entry);
config.plugins = config.plugins.concat(htmls.plugins);
This module returns an object with 2 keys.
- entry: Array of html paths to add to config.entry
- plugins: Array of html-webpack-plugin instances
example
/src/ /index.html /pages /about.html
var configHTMLs = require('webpack-config-htmls')();
finds 2 html files, adds them to entry
console.log(configHTMLs.entry);
// ['./src/index.html', './src/pages/about.html']
creates HtmlWebpackPlugin instances and adds them to plugin
console.log(configHTMLs.plugins);
/*
[
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html'
}),
new HtmlWebpackPlugin({
template: './src/pages/about.html',
filename: 'pages/about.html'
}),
]
*/
Configuration
You can pass a hash of configuration options to webpack-config-html
.
base
: folder to look for html files (defaults to './src')custom
: Array with custom option objects (to override default behaviour) (template and filename are required)
custom example:
var configHTMLs = require('webpack-config-htmls')({
custom: [{
template: './src/pages/foo.html',
filename: 'pages/bar.html'
}]
});