natrim / esbuild-plugin-inline-image

esbuild plugin for inlining yout images conditionaly on size

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug when using the plugin with react-router

emirdeliz opened this issue · comments

I have a URL like this (using react-router):

http://localhost:3110/dash/configuration

and import an image like this:

import configurationApresentation from '../../../public/images/diagrama2023.png';

After the plugin runs I have the following result in the browser:

image

However, the correct path should be this:

image

The problem occurs when the image tries to access the url ./ which in practice is http://localhost:3110/dash/configuration/diagrama2023-OBYODQFU.png.

However, the correct URL is http://localhost:3110/diagrama2023-OBYODQFU.png

How to fix this?

this plugin does not change any paths, it only inlines image if smaller than defined size
(inline means it puts it together with the js code as dataurl (ie. same as css inlined images))
it does nothing to the images otherwise