In addition to query parameters, Parcel also supports using a configuration file to define options that apply to all of the images in your project. For example, you could re-encode all images at a certain quality setting to reduce file size, or define more advanced options for each output format.
To set the quality across all images in your project, create a
sharp.config.json file in your project and define the
quality field. This will re-encode every image, not just ones referenced with query params.
You can also define more advanced options per format. All images in formats with options defined in
sharp.config.json will be re-encoded. See the full list of supported options here.
Parcel also includes lossless image optimization for JPEGs and PNGs by default in production mode, which reduces the size of images without affecting their quality. This does not require any query parameters or configuration to use. However, since the optimization is lossless, the size reduction possible may be less than if you use the
quality query param, or use a modern format such as WebP or AVIF.
To disable the default image optimization for JPEGs and PNGs in production mode, add the following to your .parcelrc configuration file: