Support for image compression
See original GitHub issueIn response to the following tweet https://twitter.com/dan_abramov/status/805036037940592641 I would love to make a pull request for adding image compression. But i do have a concern and would like to have a discussion, before proceeding with the pull request.
The webpack loader for image compression i used is https://github.com/tcoopman/image-webpack-loader I used the following config
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=static/media/[name].[hash:8].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}
i deliberately omitted pngquant support as it has been reported buggy by several user using this library (though i haven’t found any issues yet). https://github.com/tcoopman/image-webpack-loader/issues/45 https://github.com/tcoopman/image-webpack-loader/issues/42 . One other library to consider is https://github.com/thetalecrafter/img-loader. It is relatively less popular but haven’t had issues and also it fixes issues for people who had trouble with image-webpack-loader.
Any opinions ?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
@gaearon How about adding a precommit hook that runs imagemin only when there is an addition or an edit of an image?
One downside of using a loader to compress images is that it has to run for every build. I compress my images with imagemin before adding em to the repo. It has a CLI and desktop app as well. Maybe suggesting that in the docs is another option?