zouhir / lqip-loader

Low Quality Image Placeholders (LQIP) for Webpack
1.21k stars 44 forks source link

Integrate with file-loader and url-loader #8

Closed EmilTholin closed 6 years ago

EmilTholin commented 6 years ago

Thank you for your hard work with this amazing loader. I read through the source code and saw the todo comment about moving away from pitch and integrating with file-loader and url-loader. This PR does just that, and would resolve https://github.com/zouhir/lqip-loader/issues/7.

If it is used by itself, it will fall back on the new file-loader peer dependency:

{
  test: /\.(png|jpe?g)$/,
  loaders: [
    {
      loader: 'lqip-loader'
      options: {
        base64: true,
        palette: false
      }
    }
  ]
}

It can also be used in series:

{
  test: /\.(png|jpe?g)$/,
  loaders: [
    {
      loader: 'lqip-loader',
      options: {
        base64: true,
        palette: false
      }
    },
    {
      loader: "url-loader",
      options: {
        limit: 8000
      }
    }
  ]
}

This PR is currently using file-loaders value for the public path, publicPath, and not path like this loader does. If you would like this PR, we could discuss if it should be a change to the API or if I should add support for path as well.

zouhir commented 6 years ago

WOW! amazing! I'll look at that tonight and very sorry for my delayed response

zouhir commented 6 years ago

Works magically in the demo app! thanks heaps <3

EmilTholin commented 6 years ago

Awesome! Glad I could contribute.