Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use HtmlWebpackPlugin for multiple files with wildcard?

Tags:

webpack

I have many HTML files need to work with and I am using HtmlWebpackPlugin to generate them. Below is one of the config in my webpack:

new HtmlWebpackPlugin({
                filename: 'index.html',
                template: 'index.html',
                inject: 'body'
            }),

it works fine to load one HTML file. But can I use it to manage multiple files wiht wildcard? Like below configuration:

new HtmlWebpackPlugin({
                    filename: '[filename].html',
                    template: 'src/components/**/*.html',
                }),
like image 461
Joey Yi Zhao Avatar asked Dec 02 '17 00:12

Joey Yi Zhao


1 Answers

The only way to achieve this is using multiple instances of the HtmlWebpackPlugin.

Here is a sample gist explaining how it can be done: https://gist.github.com/prasann/cc797f4ab0715e7696d946647668d43b

More details on how to: https://github.com/jantimon/html-webpack-plugin/issues/218

like image 122
Prasanna Avatar answered Oct 04 '22 04:10

Prasanna