WebP solution
Enable webp:
1. Open .tmtworkflowrc
, open the configuration:
{ "supportWebp": true}
2. Execute gulp build_dist
Webp implementation process
- Convert the images in the sprite and img directories into .webp format
- Compare the converted .webp file with the original file to find the smallest file (some are larger than the original file after conversion)
- Generate the .webp.css file, which calls all the smallest files
- Cache the css address referenced by html and insert webp-related JS. When the browser loads, this JS will pre-determine whether the browser supports webp. If so, switch the css address to the corresponding .css or .webp. .css
This is a common solution for webp in front-end applications. Individuals can make corresponding adjustments according to the actual situation.