1
1
1thater2020-10-11 19:07:31
webpack
1thater, 2020-10-11 19:07:31

How to work with multiple html in webpack?

Is it possible to specify in html-webpacl-plugin which script and style files it should prescribe for itself in order to work with 2 or more html files?

After all, if you create 2 instances of html-webpacl-plugin, then they will take the same style files and scripts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LJ322, 2020-10-11
@1thater

If I understood you correctly, then you need to set up chunks for two different instances. For example:

new HtmlWebpackPlugin({
          template: __dirname + "/pages/main/main.html",
          chunks: ['main'],
          filename: './main.html',
          inject: 'body'
      }),
new HtmlWebpackPlugin({
          template: __dirname + "/pages/catalog/catalog.html",
          chunks: ['catalog'],
          filename: './catalog.html',
          inject: 'body'
      })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question