🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

mika-webpack-img2base64-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mika-webpack-img2base64-loader

这是一个将代码中引用本地资源图片(png、jpg、jpeg、gif、webp、svg格式)转换为base64格式的Webpack loader

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

mika-img2base64-loader

这是一个将代码中引用本地资源图片(png、jpg、jpeg、gif、webp、svg格式)转换为base64格式的Webpack loader

安装

npm install --save-dev ./webpack-plugins/mika-img2base64-loader

配置使用

1.在webpack.config.js中配置loader:

module.exports = {
  // ... 其他配置
  module: {
    rules: [
      // ... 其他规则
      {
        test: /\.(png|jpg|jpeg|gif|webp|svg)$/i,
        type: 'javascript/auto',
        use: {
          loader: './webpack-plugins/mika-img2base64-loader',
          options: {
            limit: 100000, // 100KB
            encoding: 'base64',
            mimetype: undefined,
            fallback: 'file-loader'
          }
        }
      }
    ]
  }
}
  • 在代码中正常导入图片:
import logo from './assets/logo.png'
image

FAQs

Package last updated on 02 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts