Skip to content
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

使用image-webpack-loader替代imagemin-webpack-plugin #36

Open
feix760 opened this issue Jun 12, 2018 · 1 comment
Open

使用image-webpack-loader替代imagemin-webpack-plugin #36

feix760 opened this issue Jun 12, 2018 · 1 comment
Labels
adjust 建议

Comments

@feix760
Copy link

feix760 commented Jun 12, 2018

https://github.com/hubcarl/easywebpack/blob/2dcd953fc93d21d3aada028250c598b5729207e3/config/plugin.js#L205

小图片我们会使用url-loader让它直接base64,但有一些图片压缩前很大,imagemin之后很小,这些文件如果用imagemin-webpack-plugin它不会base64,因为loader在plugin之前执行,url-loader limit比较的是压缩前的大小,发布出去发现有很多小图片

可以这样:

    urlimage: {
      use: [
        {
          loader: 'url-loader',
          options: {
            limit: 1024 * 5,
            fallback: 'file-loader',
            // img output path
            name: `img/[name].[hash:8].[ext]`,
          },
        },
        {
          loader: 'image-webpack-loader',
        },
      ],
    },
@hubcarl
Copy link
Collaborator

hubcarl commented Jun 12, 2018

这个可以考虑,目前你可以项目webpack.config.js 配置中可以直接这样覆盖配置

@hubcarl hubcarl added the adjust 建议 label Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adjust 建议
Projects
None yet
Development

No branches or pull requests

2 participants