Using Tinify to compress/resize images for Responsive Loader webpack loader.
npm install --save-dev responsive-loader-tinify-adapter
You will need an API key from Tinify
// Webpack config
const {
responsiveLoaderTinifyAdapter
} = require('responsive-loader-tinify-adapter');
const config = {
...
module: {
rules: [
{
test: /\.(jpg)$/,
loader: 'responsive-loader',
options: {
name: '[name]-[width].[ext]',
adapter: responsiveLoaderTinifyAdapter({
tinifyKey: [YOUR_TINIFY_KEY]
}) // You can limit this adapter only to run in production mode if you want to
}
}
]
},
...
}