S
S
skuvaWeb2019-01-15 12:09:35
JavaScript
skuvaWeb, 2019-01-15 12:09:35

Why doesn't htmlWebpackPlugin process images?

I am using HTML Webpack Plugin to process html. It works and inserts styles and scripts as it should, but it does not process the src of images.
That is, it leaves the path and filename, and when webpack builds, it changes the filenames.
my config

module.exports = {
  entry: './src/scripts/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      // imgaes
      {
        test: /\.(png|svg|jpg|gif)$/,
        use: [
          'file-loader',
        ]
      },
    ]
  },
  plugins: [

    //обработка html страниц
    ...glob.sync('src/html/*.html')
    .map(html => new HtmlWebpackPlugin({
      filename: path.basename(html),
      template: html
    })),
  ]
};

Project structure
./src/img/ -- pictures
./src/html/*.html -- html files.
Perhaps my approach is wrong? Tell me what's wrong

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question