Skip to content

是否支持先压缩完成后再使用url-loader将小图片转为base64? #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ydx425 opened this issue Jan 10, 2022 · 0 comments

Comments

@ydx425
Copy link

ydx425 commented Jan 10, 2022

我想项目中使用了url-loader来载入图片并且将大小小于4kb的图片转为base64格式,并且使用了TinyimgPlugin来压缩图片,可以正常工作。
但是我发现目前好像是先有url-loader将小图片转为base64,后面才是TinyimgPlugin压缩。这样有一个问题,有些图片本来是大于4kb没有被转为base64,经过TinyimgPlugin压缩后小于4kb了却不能再转为base64了,而且已经转为base64的图片没有被压缩,这样感觉不够完美。
希望可以告知一下是否支持先压缩后转base64?以及如何配置?感谢
目前配置:
chainWebpack: config => { config.module .rule('images') .use('url-loader') .loader('url-loader') .tap(options => Object.assign(options, {limit: 1024*4})); config .plugin('provide') .use(TinyimgPlugin, [{ enabled: process.env.NODE_ENV === "production", logged: true }]) },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant