Image not loading in React JS

411 Views Asked by At

I am new to React JS world, without web pack Image loading properly but when am using webpack Image not loading if image size greater than 24*24 pixel.

if Image size less than (24*24 pixel) then image is loading properly.

Image under src/assets/Image/exportImage.jpg'; I have no idea about this.

import exportImage from '../../assets/image/exportImage.png';
<img src={exportImage} id="ui-image"></img>

config-overrides.js

const name = '';
const publicPath = process.env.NODE_ENV === 'production' ? 'https://qiankun.umijs.org/' : 'http://localhost:3000/';
const {
    override,
    fixBabelImports,
    addLessLoader,
    overrideDevServer
} = require("customize-cra");
const path = require("path");

module.exports = override(
    fixBabelImports('import',{
        libraryName:'antd',
        libraryDirectory:'es',
        style:true
    }),
   addLessLoader({
       javascriptEnabled:true,
   })
);

module.exports = {
  webpack: function overide(config, env) {
      config.output.library = `${name}`;
      config.output.libraryTarget = 'umd';
      config.output.jsonpFunction = `webpackJsonp_${name}`;
      config.output.globalObject = 'window';
      return config;
  }
  ,
  devServer: function (configFunction) {
      return function (proxy, allowedHost) {
          const config = configFunction(proxy, allowedHost);
          config.open = false;
          config.hot = false;
          config.headers = {
              'Access-Control-Allow-Origin': '*',
          };
          return config;
      };
  },
  module: {
    rules: [
      {
        test: /\.(png|jpe?g|gif|webp|jpg)$/i,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'img/[name].[hash:8].[ext]',
              publicPath,
            },
          },
        ],
      },
      {
        test: /\.(woff2?|eot|ttf|otf)$/i,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'fonts/[name].[hash:8].[ext]',
              publicPath,
            },
          },
        ],
      },
    ],
  },
};

please help me, how can I overcome this issue.

1

There are 1 best solutions below

0
On BEST ANSWER

finally I found the solution, use the below attribute set to bigger than the image size

IMAGE_INLINE_SIZE_LIMIT