我想从webpack的jpg / png生成webp文件。 为此,我使用image-webpack-plugin( https://github.com/tcoopman/image-webpack-loader )
在插件文档中写道,webp附加优化器“将JPG和PNG图像压缩到WEBP中” (https://github.com/tcoopman/image-webpack-loader#usage),但是在遵循文档步骤之后,转换无效。
文件以jpg格式导出,但未进行任何转换。
我已经关注了这些帖子,但是我不明白如何在“非反应性”环境中进行翻译:
-
Webpack imagemin plugin to compress jpg,png and create webp?
-
Webpack (Encore): convert images to webp using image-webpack-loader
webpack.config.js
{
test:/\.(gif|png|jpe?g|svg)$/i,use:[
{
loader:'file-loader',options:{
outputPath:'images',name:'[name].[ext]'
}
},{
loader:'image-webpack-loader',options:{
mozjpeg:{
progressive:true,quality:65
},optipng:{ enabled: false },pngquant:{ quality: [ 0.65,0.90 ],speed:4 },gifsicle:{ interlaced: false },webp:{ quality: 75 }
}
}
]
}
是否有可靠,干净的方法通过webpack将jpg / png文件转换为webp?