S
S
skuvaWeb2019-01-14 22:09:08
JavaScript
skuvaWeb, 2019-01-14 22:09:08

How to properly handle html in webpack?

The task is next.
I want to create a folder with html files, and so that when generating a build assembly, my html files from the 'src/html' folder (for example) are copied to the dist folder, automatically inserting scripts, styles, pictures, and so on.
In the documentation there is HtmlWebpackPlugin
How to make it take and process not a specific file, but a folder?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-01-14
@skuvaWeb

import glob from 'glob'
import path from 'path'

{
  plugins: [
    ...glob.sync('src/html/*.html')
      .map(html => new HtmlWebpackPlugin({
        filename: path.basename(html),
        template: html
      }))
  ]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question