0

I'm learning webpack .I've read about execution order of loaders.They are executed from right to left.And the result of one loader is passed to next loader,It's clear.But than I faced with such example:

{
  test: /\.(jpe?g|png|gif|svg)$/,
  use: [
    'url-loader',
    'image-webpack-loader'
  ]
}

This example works.And it works when we change the order of loaders.I don't understand this moment.According to documentation the first loader should be 'image-webpack-loader' as it is placed at the very right.But in that case there should be error as this loader cannot work with images without url-loader.

vborutenko
  • 4,323
  • 5
  • 28
  • 48

1 Answers1

0

You are right, the order of the application of loaders is from right to left, that means with the array variation of use property it will start from the last item to the first one.

From image-webpack-loader docs, you can see that it suppose to be the last, that means that it works on the images (minimize them) before url-loader saves them to file.

Probably the opposite combination won't work.

felixmosh
  • 32,615
  • 9
  • 69
  • 88